Created
March 1, 2018 14:35
-
-
Save dcavins/c5bb41691846b809c30c72230c3c5adf to your computer and use it in GitHub Desktop.
Don't allow anyone to visit subscriber profiles.
This file contains hidden or 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
add_action( 'wp', function() { | |
if ( bp_is_user() ) { | |
$user_meta = get_userdata( bp_displayed_user_id() ); | |
if ( in_array( 'subscriber', $user_meta->roles ) ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} | |
}, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so I prematurely celebrated. So this does work however it also redirects the customer when the go to any pages like messages, buddydrive, ect;
I need to only block access to profile page but still allow them to visit the message or other tabs. I don’t use the standard buddypress design I just have custom links in the header so
members/username/messages
members/username/buddydrive
they are also redirected to homepage but I just need when they visit
members/username
Thanks again!