Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I exclude topics and replies from specific forums on the activity feed

  • @kpdub

    Participant

    Hi

    As per the topic title, I want to know how to exclude new topics and replies from specific bbpress forums from appearing on the activity feed.

    I run a gaming site and there is about 20 forums that members use to arrange things. Whilst its nice for keeping the activity feed nice and busy, a lot of good content gets missed because these forums are so busy, so I want to exclude them from the feed.

    I’ve used the code in this topic and it will exclude ALL topics and replies

    I’m a total novice when it comes to these things, so be gentle and give me an idiots guide 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • @shanebp

    Moderator

    This is not easy.

    You need to use $activity_object->secondary_item_id to get the topic id.
    Then use that to get the forum id.

    Something like this, untested:

    function imath_activity_dont_save( $activity_object ) {
        global $wpdb; 
        $exclude = array( 'bbp_topic_create', 'bbp_reply_create');
        $exclude_forum_ids = array( 1, 23, 44 ); // the ids of the specific forums to exclude
    
        if( in_array( $activity_object->type, $exclude ) ) {
           $topic_id = $activity_object->secondary_item_id;
           $forum_id = $wpdb->get_var("SELECT post_parent FROM {$wpdb->prefix}posts WHERE ID = $topic_id");
            if( in_array( $forum_id, $exclude_forum_ids ) ) 
                $activity_object->type = false;
        }
    }
    add_action('bp_activity_before_save', 'imath_activity_dont_save', 10, 1 );

    @shanebp

    Moderator

    I’m not sure if bbPress functions are available via that action hook, but if they are then this might work:

    function imath_activity_dont_save( $activity_object ) {
    
        $exclude = array( 'bbp_topic_create', 'bbp_reply_create');
        $exclude_forum_ids = array( 1, 23, 44 ); // the ids of the specific forums to exclude
    
        if( in_array( $activity_object->type, $exclude ) ) {
           $forum_id = bbp_get_forum_id();
            if( in_array( $forum_id, $exclude_forum_ids ) ) 
                $activity_object->type = false;
        }
    }
    add_action('bp_activity_before_save', 'imath_activity_dont_save', 10, 1 );

    @kpdub

    Participant

    Thanks for the reply

    Are you suggesting using the first, second or both solutions?

    Where do I post them?

    I’m considering installing a separate forum plugin to manage this area if the above doesn’t work.

    @shanebp

    Moderator

    Try the 2nd one first.
    Put it in your theme/functions.php or in bp-custom.php – a file you may need to create.

    @kpdub

    Participant

    Thanks for this, tested it out over the last week now and works brilliantly

    Thankyou again

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I exclude topics and replies from specific forums on the activity feed’ is closed to new replies.
Skip to toolbar