Last active
January 7, 2020 16:33
-
-
Save nfsarmento/900086d0e9a1e04a37f51565e6cb6729 to your computer and use it in GitHub Desktop.
Show content based on multiple user roles in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $user_login, $current_user; | |
wp_get_current_user(); | |
$user_info = get_userdata($current_user->ID); | |
$roles = array ( | |
'administrator', | |
'subscriber', | |
); | |
if (is_user_logged_in() && array_intersect( $roles, $user_info->roles)) { | |
echo 'success'; | |
} else { | |
echo 'failure'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment