Skip to content

Instantly share code, notes, and snippets.

@juancamiloqhz
Last active August 15, 2018 22:48
Show Gist options
  • Select an option

  • Save juancamiloqhz/b595cdad40686fc958cc0288025bdbd4 to your computer and use it in GitHub Desktop.

Select an option

Save juancamiloqhz/b595cdad40686fc958cc0288025bdbd4 to your computer and use it in GitHub Desktop.
If current user is subscriber WordPress
<?php
global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( ! user_can( $current_user, "subscriber" ) ) // Check user object has not got subscriber role
echo 'User is a not Subscriber';
else
echo 'User is a Subscriber';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment