Skip to:

Hide All Admins from All Buddypress Activities

Viewing 5 replies - 1 through 5 (of 5 total)

  • Henry Wright


    In post #190874 on the topic you’ve linked to, snippet 2 has the line:

    $excluded_user='1'; // Id's to remove, separated by comma

    You can just add more user IDs like this and those IDs will be excluded from the loop:

    $excluded_user='1,34,56,201'; // Id's to remove, separated by comma



    Thanks a lot for the explanation @henrywright. I eventually used the following code from

    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
    function buddydev_exclude_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 );
        $user_ids = array( 1,2,3 ); //user ids
        $excluded = array_merge( $excluded, $user_ids );
        $args['exclude'] = $excluded;
        return $args;

    It worked in hiding users from directories/widgets/friend lists, only that it didn’t also handle profile redirect. I had to set up redirects to homepage for all the admin accounts on server side.

    Thanks again for your assistance on this.



    Thanks for the reply on this and sorry just now getting back…life got in the way…can you explain in newbie elementary terms exactly what you were discussing in regards to having me show up as admin and not just looking like a logged in user on buddypress…what is happening is…when I log into my wordpress I show up on my webpage as like a logged in user..doesn’t say admin or anything…I want to be displayed as a admin/moderator for the site…how do I do this…in elementary terms please as I am new to WordPress although I have learned so much and have actually almost put up a complete website…but I am even newer to buddypress although I have it up on my site…these little kinks such as this one are getting in the way…thankful for this buddypress support forum….if you could help I would greatly appreciate it!! Rhonda



    Hi, struggling to get any of the the code in post #190874 to work. I have created a bp-custom.php file which I have uploaded to the root of the buddpress folder and my code looks like this:

    // deny access to admins profile. User is redirected to the homepage
    function bpfr_hide_admins_profile() {
    	global $bp; 
    	if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
    		wp_redirect( home_url() );
    add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
    // Remove admin from the member directory
    function bpdev_exclude_users($qs=false,$object=false){
        $excluded_user='1'; // Id's to remove, separated by comma
        if($object != 'members' && $object != 'friends')// hide admin to members & friends 
        return $qs;
        return $qs;	
    		$args['exclude'] = $args['exclude'].','.$excluded_user;
    		$args['exclude'] = $excluded_user;
        $qs = build_query($args);
        return $qs;
    // once admin is removed, we must recount the members !
    function bpfr_hide_get_total_filter($count){
        return $count-1;
    // hide admin's activities from all activity feeds
    function bpfr_hide_admin_activity( $a, $activities ) {	
    	// ... but allow admin to see his activities!
    	if ( is_site_admin() )	
    		return $activities;	
    	foreach ( $activities->activities as $key => $activity ) {	
    		// ID's to exclude, separated by commas. ID 1 is always the superadmin
    		if ( $activity->user_id == 1  ) {			
    			unset( $activities->activities[$key] );			
    			$activities->activity_count = $activities->activity_count-1;			
    			$activities->total_activity_count = $activities->total_activity_count-1;			
    					$activities->pag_num = $activities->pag_num -1;				
    	// Renumber the array keys to account for missing items 	
    	$activities_new = array_values( $activities->activities );		
    	$activities->activities = $activities_new;	
    	return $activities;
    add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );

    Not sure what I am doing wrong. All help gratefully received! Thanks



    …which I have uploaded to the root of the buddpress folder

    It should go in the root of the plugins folder.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide All Admins from All Buddypress Activities’ is closed to new replies.
Skip to toolbar