admin管理员组文章数量:1310027
When I logged into the specific multi-site, I am trying to get current login user details, I already used below one but this function returning null. How, can I get currents logged in user information. I am actually trying to get user email
$logged_in_user = wp_get_current_user();
if($logged_in_user->ID != 0){
$email = $logged_in_user->user_email;
}
When I logged into the specific multi-site, I am trying to get current login user details, I already used below one but this function returning null. How, can I get currents logged in user information. I am actually trying to get user email
$logged_in_user = wp_get_current_user();
if($logged_in_user->ID != 0){
$email = $logged_in_user->user_email;
}
Share
Improve this question
edited Jul 25, 2017 at 12:48
bravokeyl
3,3776 gold badges27 silver badges33 bronze badges
asked Jul 25, 2017 at 12:40
bharath goudbharath goud
11 bronze badge
3
|
1 Answer
Reset to default 1As described in the documentation, you have call this inside a hook.
For wordpress versions < 3.4: use the init or any subsequent action to call this function. Calling it outside of an action can lead to troubles. See #14024 for details.
Example:
add_action('init', 'get_user_email');
function get_user_email() {
$logged_in_user = wp_get_current_user();
if($logged_in_user->ID != 0){
$email = $logged_in_user->user_email;
}
}
本文标签: plugin developmentHow to get current loggedin user details in multisite
版权声明:本文标题:plugin development - How to get current logged-in user details in multisite? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741826850a2399695.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
get_currentuserinfo()
, so you can use. It's important, though, to only call it on or after the init hook. Calling it before will only return 0 – Devendra Sharma Commented Jul 25, 2017 at 12:44