How to get current user id from a plugin?
-
I am a new begginer in wordpress, now i am using wordpress 2.8 beta.
I wanna use a user permission in my plugin so i create a table named “group”, the fields in the table are “user_id” and “group”.
When a user login and log to my plugin, i wanna know their group so the plugin will display what the user level can do / see. It will required the current user_id.How to get current user_id in my plugin??
I have use this code in one of my function in my plugin :
<?php
global $current_user;
get_currentuserinfo();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”);
?>then it got an error :
Fatal error: Call to undefined function get_currentuserinfo() in C:\wamp\www\wm\wp-content\plugins\wm_manager\includes\wm_manager.class.php on line 112Please help me to solve this.
Thanks very much for your help.
The topic ‘How to get current user id from a plugin?’ is closed to new replies.