Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prevent Group Post from Showing on Profile Activity


  • balebond
    Participant

    @balebond

    Trying to figure out if there is a way to prevent group activity and group forum posts from showing on a member’s profile page activity. Site-wide is ok. They just want personal page to to be posts they posted there.

    Thanks for any help.

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

  • balebond
    Participant

    @balebond

    Just found a near-hit for my needs in this post by @modemlooper:

    https://buddypress.org/support/topic/disable-group-posts-from-main-activity-stream/

    However, the code below is stripping group posts from both the “Activities” page and a member’s page activity. I tried to limit to user pages only by altering if ( bp_is_current_component( ‘activity’ ) to if ( bp_is_current_component( ‘profile’ ) but didn’t work. Anyone see what I need to change so that this snippet only fires if it is on a member’s activity page?

    function bp_filter_groups_from_activity( $a, $activities ) {
    
    	if ( bp_is_current_component( 'activity' ) ) {
    		foreach ( $activities->activities as $key => $activity ) {
    			
    			if ( $activity->component =='groups') {
    				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;
    			}
    		}
    		 
    		$activities_new = array_values( $activities->activities );
    		$activities->activities = $activities_new;
    		 	
    	}
    	return $activities;
    }
    add_action('bp_has_activities','bp_filter_groups_from_activity', 10, 2 );

    shanebp
    Moderator

    @shanebp

    Try :
    if ( bp_is_current_component( 'activity' ) && bp_is_user() ) {


    balebond
    Participant

    @balebond

    Have to do a little more testing but this looks like it did the trick! Thanks for the quick reply. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar