Skip to:
Content
Pages
Categories
Search
Top
Bottom

Excluding One Blog’s Activities from bp_has_activities?

  • I’m running BP on a multisite WP installation along with the sitewide tags plugin to pull blog posts from child sites into the main site, essentially making a copy of all child site posts on the main site as if they’d been written there originally. Since blog owners’ posts to their child site blogs also post to their main site profiles, this is causing double posts to the activity stream. You can see an example here (one post will say “on the site ________” and the double will say “on the site RiotCart.com”):

    http://www.riotcart.com/activity

    I’d like to eliminate the doubles that say “on the site RiotCart.com”, which is my main blog, ID# 1. I’m assuming this is done on activity/activity-loop.php, somehow using bp_has_activities(), but am fuzzy on where to go from there.

    I have read the doc for the activity loop, and I’ve gotten as far as the following (which I assume is way off, but it’s a starting point, at least). Where in my activity/activity-loop.php would it go? I’m assuming that this will exclude EVERYTHING about blog #1, so how do I specify to allow everything from ID# 1 EXCEPT blog posts?

Viewing 10 replies - 26 through 35 (of 35 total)

  • Ron Rennick
    Participant

    @wpmuguru

    Will your mention of @wpmuguru send them a notification?

    Yes it does :D

    The meta key is sitewide_tags_blog and it contains an array. However if you want to disable SWT on a single blog / site I have a post here: http://wpmututorials.com/plugins/turn-off-sitewide-tags-on-special-blogs/

    Thanks for checking in!

    I tried the fix that you linked to, but it didn’t work in my case :(

    One more question, and then I will try to leave everyone alone, promise!

    Would anyone be willing to give me the SQL query to plug into phpMyAdmin that will delete all of the new blog post from blog ID 1 (or, by name: RiotCart.com) activity entries from my db altogether? I’m still testing my fix, but even if it does work, there’s still the issue of my activity stream being all clogged up by the doubles from the past, and I really need to get rid of those.


    Boone Gorges
    Keymaster

    @boonebgorges

    Here’s what you’ll need, though I will also say that you should not do this, and I accept no responsibility for what goes wrong:

    `DELETE FROM wp_bp_activity WHERE component = ‘blogs’ AND item_id = ‘1’;`


    Boone Gorges
    Keymaster

    @boonebgorges

    <– Note that this will delete all activity items related to blog id 1. If you need only to delete new blog post notifications:
    `DELETE FROM wp_bp_activity WHERE type = ‘new_blog_post’ AND item_id = ‘1’;`


    nm
    Participant

    @nahummadrid

    @justbishop so you were featuring posts using Activity Items for blog posts on the index, how are you doing that? I mean the block activity stream types would have always been the fix I think to get rid of those dupes. I’ve done it plenty of times with the snippet I added earlier and including using the fix from wpmuguru, I’ve always been able to eliminate dupes. So really the only problem holding you back was your index post feature-feature, um yea that thing. Wouldn’t you say that was holding you back here?

    @boonebgorges, thanks, and I have to ask why would you advise against doing it? Having those duplicates in the activity stream is actually an extremely bad thing for my site, because they are essentially items for sale. If a user is able to view the copy of a post made to my main site by the SWT plugin (as you are able to on certain posts that have been natively posted to one of my network’s child sites), the “add to form” cart renders using MY paypal info, rather than the seller’s info, as it does when you view the item on their site!

    Here is an example of a child site post (copied to the main site via SWT) that you can get to via one of the duplicate activity entries:

    http://www.riotcart.com/blog/2011/01/30/medium-juliette-skirty/

    And here is the item on the seller’s own site (a child site on my network):

    http://www.riotcart.com/hedgieshideaway/?p=115

    As you can imagine, it’s extremely important that users/front-end viewers are NOT given the option of which version (the original or the copy to the main site) they’d like to click into!

    @nahummadrid, I honestly have no idea what was going on. Like I mentioned, as soon as I removed the “before_blog_post” and “after_blog_post” BP codes from around my query for the featured post, the problem was non-existent, and I was able to just use the block activity stream types plugin you had recommended :D

    For the record, here is my query for the featured post. I use the Featured Content Showcase plugin for various reasons, but it displays a slideshow. All I wanted was one static, random post with an image, title, and excerpt on each page load, so I dug around and found the meta key/velue that the FCS plugin was adding to posts marked as featured, and ran with it:

    `$args=array(
    ‘orderby’ => ‘rand’,
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’,
    ‘numberposts’ =>1,
    ‘post_type’ => ‘post’,
    ‘meta_key’ => ‘_fcs_featured’,
    ‘meta_value’ => ‘true’,
    );

    $latest = get_posts($args);
    $count = 0;
    foreach($latest as $post) {

    $blogid = get_post_meta($post->ID, ‘blogid’, true);
    $image = get_post_meta($post->ID, ‘thumbnail’, true);
    $title = get_post_meta($post->ID, ‘_fcs_title’, true);
    $text = get_post_meta($post->ID, ‘_fcs_text’, true);
    if ( empty($title) ) {
    $title = get_the_title($post->ID);
    }

    if ( empty($text) ) {
    $text = $post->post_excerpt;
    if ( post_password_required($post) ) {
    $text = __(‘There is no excerpt because this is a protected post.’);
    } elseif ( !empty($post->post_excerpt) ) {
    $text = apply_filters(‘get_the_excerpt’, $post->post_excerpt);
    } else {
    $text = $this->_makeExcerpt($post->post_content);
    }
    }`


    Boone Gorges
    Keymaster

    @boonebgorges

    > I have to ask why would you advise against doing it?

    Because if you go and mess up your database because you’ve got your sticky fingers in there, I don’t want you to come and blame me!

    LOL, I would never do that (and I would export a backup first). Under those conditions, does it seem like a safe choice?

    Nevermind, did it, and your 2nd query worked like a charm, @boonebgorges! Thanks :)

    P.S. I did make a db backup, and will hang onto it just in case some wonkiness that I’m just not seeing yet crops up ;)

Viewing 10 replies - 26 through 35 (of 35 total)
  • The topic ‘Excluding One Blog’s Activities from bp_has_activities?’ is closed to new replies.
Skip to toolbar