In WordPress there are many users with different roles. A user may have a administrator role, author or any other roles from the standard roles defined by WordPress.
If you want to find out user role or user information such as name,ID etc you can use the following function.
If you want to find out user role or user information such as name,ID etc you can use the following function.
<?php
$user_info = get_userdata(1);
echo 'Username: ' . $user_info->user_login . "\n";
echo 'User roles: ' . implode(', ', $user_info->roles) . "\n";
echo 'User ID: ' . $user_info->ID . "\n";
?>
The above will give you user's username, role and ID.
No comments:
Post a Comment