registred user using WP







Get registred user role in wordpress



The simplest and the easiest way to do so is to use get_userdata() wordpress function.
The example of code is given bellow

global $wpdb;
$user_id = get_current_user_id();
$user_info = get_userdata($user_id);
echo ‘Username: ‘ . $user_info->user_login . “\n”;
echo ‘User roles: ‘ . implode(‘, ‘, $user_info->roles) . “\n”;
echo ‘User ID: ‘ . $user_info->ID . “\n”;
?>

0 comments: