Skip to content

Instantly share code, notes, and snippets.

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 dcavins/c5bb41691846b809c30c72230c3c5adf to your computer and use it in GitHub Desktop.
Save dcavins/c5bb41691846b809c30c72230c3c5adf to your computer and use it in GitHub Desktop.
Don't allow anyone to visit subscriber profiles.
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 );
@kwavewd
Copy link

kwavewd commented Mar 1, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment