Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Own profile and administrator profile are listed in the members directory

$
0
0

Replies: 0

Hi there, when I block a user, my own profile and administrator profile are listed in the members directory.

I am using this code to exclude logged and admin users from BuddyPress users list which is not working with the plugin activated:

function buddydev_exclude_logged_and_admin_users( $args ) {
	//do not exclude in admin
	if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
		return $args;
	}

	$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();

	if ( ! is_array( $excluded ) ) {
		$excluded = explode( ',', $excluded );
	}

	$role     = 'administrator';//change to the role to be excluded
	$user_ids = get_users( array( 'role' => $role, 'fields' => 'ID' ) );

	$excluded = array_merge( $excluded, $user_ids );

	if ( is_user_logged_in() ) {
		array_push( $excluded, get_current_user_id() );
	}

	$args['exclude'] = $excluded;

	return $args;
}

add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_logged_and_admin_users' );

How do solve this issue?

Best
Carsten


Viewing all articles
Browse latest Browse all 59525

Trending Articles