Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • @nicolemb

    Participant

    Thanks @shanebp. We tried this and a few other hooks and still have not been able to get the appropriate activity on the stream.

    It does seem like the issue with this mu-plugin solution is that not every bit of activity is getting assigned the site id in the meta data. So the filter ends up filtering out most of the activity we should see. Ultimately we are seeking a way to limit activity stream data to the site you are visiting without using multi-network plugins.

    We have a wordpress multisite network with buddypress NOT network activated but only activated on specific subsites.

    Do you or anyone have any suggestions on how to achieve our goals?

    @nicolemb

    Participant

    Thanks @shanebp – This is our problem. This whole solution hinges on adding meta with the blog id to EVERYTHING that could appear in an activity stream. (We also have Activity Plus Plugin active on one site and those posts seem to be missing getting the meta added)

    Is there something we hook to in order to add meta to all activity? we tried add_action('bp_activity', 'where_activity_from', 10, 3); but it’s still not adding meta to all.

    Or is there a better way to filter activity streams to only show activity from the current site on a multisite setup?

    Here’s our latest attempt at a must-use plugin, but not all activity is shown implying the meta values are not being added:

    <?php
    
    // Add Blog ID meta to activity posts
    add_action('bp_activity', 'where_activity_from', 10, 3);
    function where_activity_from($content, $user_id, $activity_id)
    {
        bp_activity_add_meta($activity_id, '_source_blog', get_current_blog_id());
    }
    
    // Filter specific sites for activity from that site only
    function bp_after_has_activities_parse_args_func($r)
    {
        $blog_id = get_current_blog_id();
        global $wpdb;
        $sql = $wpdb->prepare("SELECT activity_id FROM " . $wpdb->base_prefix . "bp_activity_meta WHERE meta_key=%s AND meta_value=%d", '_source_blog', $blog_id);
    
        $ids = array_values($wpdb->get_col($sql));
        if (empty($ids)) {
            $r['in'] = '-1';
        } else {
            $r['in'] = $ids;
        }
        return $r;
    }
    
    if (get_current_blog_id() !== 1) {
        add_filter('bp_after_has_activities_parse_args', 'bp_after_has_activities_parse_args_func');
    }

    @nicolemb

    Participant

    I am also seeking this solution for a site I’m building. I’m currently going with Events Manager, but would love to see something like this developed and would be willing to help in anyway I can.

Viewing 3 replies - 1 through 3 (of 3 total)
Skip to toolbar