Created
May 29, 2013 18:31
-
-
Save strangerstudios/5672579 to your computer and use it in GitHub Desktop.
Keep users with no role from viewing a WordPress site.
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
/* | |
Keep users with no role from viewing the site. | |
From the WP dashboard, go to Users to find the user, | |
then edit the user and change role to "no role for this site". | |
*/ | |
function my_no_role_lockout() | |
{ | |
if(is_user_logged_in()) | |
{ | |
global $current_user; | |
if(empty($current_user->roles)) | |
{ | |
//log them out | |
wp_logout(); | |
//show an error | |
die("Your account has been banned from using this site."); | |
} | |
} | |
} | |
add_action("init", "my_no_role_lockout", 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment