简体   繁体   中英

wordpress logged in user in storyboard

trying to get logged in user in wordpress from within lightbox plugin:

[iframe_loader type='lightbox' href='https://www.website.org/wp-content/uploads/articulate_uploads/TestCert/' size_opt='lightebox_default']

this is a storyboard test that send results to a php page - code in php page is:

<?php
$current_user = wp_get_current_user();
/**
 * @example Safe usage: $current_user = wp_get_current_user();
 * if ( !($current_user instanceof WP_User) )
 *     return;
 */
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
?> 

The PHP needed the include_once to point to wp-blog-header.php within WordPress for the function to run.

include_once ( "../public_html/wp-blog-header.php" );

global $current_user;

echo 'Username: ' . $current_user->user_login . "\n";
echo 'User email: ' . $current_user->user_email . "\n";
echo 'User level: ' . $current_user->user_level . "\n";
echo 'User first name: ' . $current_user->user_firstname . "\n";
echo 'User last name: ' . $current_user->user_lastname . "\n";
echo 'User display name: ' . $current_user->display_name . "\n";
echo 'User ID: ' . $current_user->ID . "\n";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM