How to get current logged-in user details of a blog in wordpress? -
when logged specific multi-site blog, trying current login user details, used below 1 function returning null. how, can currents logged in user information. trying user email
$logged_in_user = wp_get_current_user(); wp_get_current_user(); return below object empty values wp_user object { back_compat_keys => array(6) ( [user_firstname] => (string) first_name [user_lastname] => (string) last_name [user_description] => (string) description [user_level] => (string) wp_user_level [wp_usersettings] => (string) wp_user-settings [wp_usersettingstime] => (string) wp_user-settings-time ) data => stdclass object id => (int) 0 caps => array(0) cap_key => null roles => array(0) allcaps => array(0) filter => null }; //email if($logged_in_user->id != 0){ $email = $logged_in_user->user_email; }
first, comment out line:
wp_get_current_user(); return below object empty values
then, user details this:
$userid = $logged_in_user->id; $useremail = $logged_in_user->user_email; //and on there.
you can find more examples in this tutorial here.
Comments
Post a Comment