Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filter State-Wide Activities From Groups


  • naomibuch
    Participant

    @naomibuch

    Hi there,

    I have searched far and wide for a solution to filter Activites from Public Groups. I have managed to filter Groups with this code ` 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 );

    `
    But every time a user posts in the Activity Stream the post shows up in all Groups that the user is a member of.

    I would like to have Group comments separately like Facebook Groups.

    Any help would be appreciated.

    Thanks a bunch.

    Naomi

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

  • Nahum
    Participant

    @nahummadrid


    naomibuch
    Participant

    @naomibuch

    Hi there,

    That worked!! Thanks a bunch

    Naomi


    naomibuch
    Participant

    @naomibuch

    @nahummadrid ….It sort of worked …When I changed the privacy level to friends the activity posts show in all groups that I am a member of, it only works if I change my privacy level to public…any more ideas?

    Thanks,
    naomi


    Nahum
    Participant

    @nahummadrid

    @naomibuch I think I see what you are saying.

    Private group activities are appearing in the sitewide feed? Is that right?


    naomibuch
    Participant

    @naomibuch

    @nahummadrid….No, I have all public groups that anyone can join, BUT, I don’t want the comments that don’t pertain to a Group to show up in a Group.

    For example, If I post “Good morning friends” in the Activity Stream for friends only and I have a Public Group called “Politics” that anyone can join, I don’t want my post “Good morning friends” showing up the “Politics” public Group.

    Currently, I have the privacy option the restrict each post to Public, Friends and Only me. But the Group code you gave me only works if I set the privacy to public.

    I hope that explains the situation better.

    Thanks,
    Naomi


    Nahum
    Participant

    @nahummadrid

    Sounds like something is messing with the default behaviour then. Personal activity updates would never appear in any group unless it was “post in group”, vs “post in profile”

    Do you have a filter or plugin already set to do private sitewide activity stream?

    “Activity Stream for friends only” & “Currently, I have the privacy option the restrict each post to Public, Friends and Only me. But the Group code you gave me only works if I set the privacy to public.”


    naomibuch
    Participant

    @naomibuch

    @nahummadrid …You are correct, I did some troubleshooting and I have Youzer plugin installed that enhances the design and when I deactivated the plugin the friend’s activities don’t in Groups, I will contact the plugin author.

    Thank you very much for leading me in the right direction.

    Naomi


    craighamilton
    Participant

    @craighamilton

    Try using this filtering structure.

    add_filter( ‘bp_before_has_activities_parse_args’, function( $args ) {

    if(bp_is_current_action( ‘groups’ )) {

    $args[‘object’] = array(‘groups’);

    } else {
    $filter_query = array(
    array(
    ‘column’ => ‘type’,
    ‘value’ => array( ‘group_action_1’, ‘group_action_etc’ ),
    ‘compare’ => ‘NOT IN’,
    ),
    );

    $args[‘filter_query’] = $filter_query;
    }

    return $args;
    } );

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