Skip to:
Content
Pages
Categories
Search
Top
Bottom

restrict some users to not display on page members

  • @pws2015

    Participant

    Hello,
    i use buddypress plugin Version 2.3.4
    I want restrict some users as admin account to not display in members page on frontend.
    How i can do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • @danbp

    Participant

    hi @pws2015,

    try this. Add snippets to bp-custom.php

    First snippet is mandatory, second is an option. Note that hidden members activities and profiles stay public. The below code let you only hide users from the members directory.

    // hide members on directory
    function bpfr_hide_users_on_directory( $qs=false, $object=false ){
    	
    	// Id's to hide, separated by comma
    	$excluded_user = '5,38,30'; 
    
    	// hide to members & friends 
    	if($object != 'members' && $object != 'friends')
    	return $qs;
    	
    	$args = wp_parse_args($qs);
    	
    	if(!empty($args['user_id']))
    	return $qs;	
    	
    	if(!empty($args['exclude']))
    	$args['exclude'] = $args['exclude'].','.$excluded_user;
    	else
    	$args['exclude'] = $excluded_user;
    	
    	$qs = build_query($args);
    	
    	return $qs;
    	
    }
    add_action( 'bp_ajax_querystring','bpfr_hide_users_on_directory', 20, 2 );
    
    // once hidden, we recount the members
    function bpfr_hide_get_total_filter($count){
    	return $count-1;
    }
    add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');

    @pws2015

    Participant

    hi,

    thanks..
    haven’t plugin do this (not chnages source code)? and not display from all pages, map, search form… ??

    @danbp

    Participant

    Sorry, i don’t understand what you write.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘restrict some users to not display on page members’ is closed to new replies.
Skip to toolbar