Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide Admin Does Not Work in BP 2.8


  • livingflame
    Participant

    @livingflame

    Hi there!

    I have this code —-> But this code does not work anymore with BuddyPress 2.8

    // 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 );

    And, I have other code, but this only hide admin from Directories and Bp Widgets.

    // Exclude Admins from Directories and BP Widgets 
    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, ); // enter user ids here
        $excluded = array_merge( $excluded, $user_ids );
        $args['exclude'] = $excluded;
        return $args;
    }
  • You must be logged in to reply to this topic.
Skip to toolbar