How to get the currently logged in user's role in wordpress?
+3
A:
Assuming you have the user id ($user_id) something like this should work:
$user = new WP_User( $user_id );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
echo $role;
}
Get the user id from your session.
link664
2009-09-22 06:12:30
Thanks, this works for me.
Ravi
2009-09-22 06:57:00