How to get user role in wordpress or how to work with the user role condition in wordpress?

<?php
global $current_user;
get_currentuserinfo();
$myuser= "$current_user->ID";
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
?>


<?php
if ($user_role == 'contributor') {
?>

// your code is here //

<?php
}
?>

No comments:

Post a Comment