How can I get current user id in plugin? I tried to use $current_user->ID but it doesn't work (works fine in template files). Any other way?
Thanks
How can I get current user id in plugin? I tried to use $current_user->ID but it doesn't work (works fine in template files). Any other way?
Thanks
same problem for me. I want to get current page ID or name inside plugin
global $current_user;
echo $current_user->ID;
If a variable is outside the scope of where you're trying to call it, then you need to globalise that variable..
it's not working in wordpress 2.9...
is there another solution?
global $current_user;
get_currentusrinfo();
echo $current_user->ID;small fix:
global $current_user;
get_currentuserinfo();
echo $current_user->ID;Thank you. :)
This topic has been closed to new replies.