Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Last active April 9, 2018 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/19e20ff40821f48daa739075bce83631 to your computer and use it in GitHub Desktop.
Save whoisryosuke/19e20ff40821f48daa739075bce83631 to your computer and use it in GitHub Desktop.
WORDPRESS: Check if user has certain role
<?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