BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 3
    berzerk on #52183

    Thanks. Working good now. If I update the plugins now through Plugins page, it should be safe to do? Don’t want to risk the plugins going corrupt, lol.

  • Participant
    Level: Initiated
    Posts: 3
    berzerk on #51427

    Hello Brajesh,

    You are the GOAT! I would like to exclude contributor accounts too. Is the below code how you would do it? Sourced from one of your comments on the original blog posts.

    /**
     * Exclude Users from BuddyPress Members List by WordPress role.
     *
     * @param array $args args.
     *
     * @return array
     */
    function buddydev2_exclude_users_by_role( $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 );
    	}
    
    	$user_ids =  get_users( array( 'role__in' => ['administrator' , 'contributor'] ,'fields'=>'ID') );
    
    	$excluded = array_merge( $excluded, $user_ids );
    
    	$args['exclude'] = $excluded;
    
    	return $args;
    }
    
    add_filter( 'bp_after_core_get_users_parse_args', 'buddydev2_exclude_users_by_role' );
  • Participant
    Level: Initiated
    Posts: 3
    berzerk on #51411

    It is good to be here!

    Thank you for the caution and explanation, much appreciated. And thank you for your willingness to share the code, I’d like to try your code.

    Cheers.