Skip to:
Content
Pages
Categories
Search
Top
Bottom

Stop posts and updates from a single blog showing up in the mainpage activity stream

  • @markhahnel

    Participant

    Is it possible to stop posts and updates from a single blog showing up in the mainpage activity stream.

    I am running wpmu 3.0.1 bp 1.2.5.2 and have about 10 blogs running. I want to add a new blog but do not want the updates to show up in the main page activity stream.

    Any help much appreciated!

Viewing 17 replies - 1 through 17 (of 17 total)
  • @rogercoathup

    Participant

    Two options spring to mind:

    1. You could add a filter on new blog posts creating an activity stream entry, check the blog id, and exclude appropriately. A bit of searching in the BuddyPress plugin files should find the correct filter to add.

    2. Or, in your activity stream loop, check the activity item id and don’t display if it’s for the blog you want to exclude

    @markhahnel

    Participant

    Thanks @Rogercoathup – Where would I find the activity stream loop?

    @rogercoathup

    Participant

    @markhahnel

    You can adapt the code snippet in here by changing the blog id: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/posts-of-the-main-blog-in-site-wide-activity/

    If your theme follows the default structure, you’ll find your activity loop in my-theme/activity/activity-loop.php

    Also have a look at the custom loop documentation (click documentation under support tab) on this site

    @nuprn1

    Participant

    think i’m going to update my block activity type plugin to allow more granular control over the item_id and types

    but here is a code snippet i quickly modified from that plugin (untested – so double check). in theory, just replace INSERT_THE_BLOG_ID_HERE with the blog_id you want to block. (note this blocks new updates to the db, you would need to remove previous ones)

    `
    //if php is older then change $a to &$a
    function my_block_activity_type_blog_id_before_save( $type, $a ) {
    global $bp;

    //if there is an id – we don’t care… updating
    if ( $a->id )
    return $type;

    //Come and see the violence inherent in the system. Help! Help! I’m being repressed!
    if ( $a->type == ‘new_blog_post’ || $a->type == ‘new_blog_comment’ ) {

    //item_id is the blog_id in this context
    if ( $a->item_id == INSERT_THE_BLOG_ID_HERE ) {
    $a->type = null;
    return null;
    }
    }

    //otherwise continue if nothing happened
    return $type;
    }
    add_filter(‘bp_activity_type_before_save’, ‘my_block_activity_type_blog_id_before_save’, 9999, 2);
    `

    @markhahnel

    Participant

    Thanks @rofercoathup and thanks @nuprn1

    Rich, where would I add that code, to the activity loop?

    Thanks again.

    @nuprn1

    Participant

    functions/bp-custom file – but with that code snippet you won’t be able to recover the data going forward (blocked from the db) – make sure you test it

    @rogercoathup

    Participant

    @markhahnel

    The solution from @nuprn1 is essentially the details for implementing option 1 that I suggested above, the code snippet I gave you is the option 2 solution.

    @markhahnel

    Participant

    Thats fine @nuprn1 , I dont want to recover data. I am quite experienced with this now, but I cant find the functions folder, in the theme editor, it isnt there, is it in the buddypress plugin file? Im using suffusion theme?

    Thanks a lot Rich

    @markhahnel

    Participant

    Thanks @rogercoathup – do you know where I’d find this file to edit? Thanks

    @markhahnel

    Participant

    Ok guys, so I think I should be going to bp-default theme in the theme editor, and copying in the code that rich gave me but putting the blog id in. ie. in this case ‘blogstest’.

    If so, its not working? Am I going to the wrong place?

    @nuprn1

    Participant

    search up on placing code snippets in the theme’s function.php or creating a bp-custom.php

    the blog_id is not the name of the blog but rather the numerical value in the db for that blog.

    @markhahnel

    Participant

    Ahh, thanks @nuprn1 – I have a bp-custom file, Im just being stupid. Just the numerical id to find. Thanks again.

    @markhahnel

    Participant

    @nuprn1 – That one doesnt work – I’m going to give @rogercoathup s suggestion a go.

    @markhahnel

    Participant

    @rogercoathup @nuprn1 – Both dont seem to work.

    @markhahnel

    Participant

    Can anyone else think of any other snippets I can add to the bp-custom.php to block new posts in one specific blog showing up in the activity stream?

    ie. My blog_id is 282 and I have tried the 2 codes above?

    @markhahnel

    Participant

    Stop the clock @nuprn1 – Yours worked, I hadnt opied the code completely, missing the //

    You guys are great, thanks for the help @rogercoathup

    Thanks

    @nuprn1

    Participant

    :-P thanks for testing it… i’ll add this to my plugin after bp1.2.6 hits. i see this question a bit (along with blocking a certain blog category)

Viewing 17 replies - 1 through 17 (of 17 total)
  • The topic ‘Stop posts and updates from a single blog showing up in the mainpage activity stream’ is closed to new replies.
Skip to toolbar