Last active
April 9, 2018 20:27
-
-
Save whoisryosuke/19e20ff40821f48daa739075bce83631 to your computer and use it in GitHub Desktop.
WORDPRESS: Check if user has certain role
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 | |
# Credit: https://wordpress.stackexchange.com/questions/5047/how-to-check-if-a-user-is-in-a-specific-role | |
$user = wp_get_current_user(); | |
if ( in_array( 'author', (array) $user->roles ) ) { | |
//The user has the "author" role | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment