Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: deny access to subscriber profile

@dcavins

Keymaster

Here’s some untested code that should prevent anyone from visiting the profile of a subscriber user. Roles are not a BP construct, so you’ve got to look to WordPress for that info.


add_action( 'wp', function() {
	if ( bp_is_profile() ) {
		$user_meta = get_userdata( bp_displayed_user_id() );

		if ( in_array( 'subscriber', $user_meta->roles; ) ) {
			wp_redirect( home_url() );
			exit;
		}
	}
}, 1 );
Skip to toolbar