Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filtering Activity Stream


  • Keith Kelly
    Participant

    @fanoop

    I am trying to create an aggregated activity stream for my site so basically when a user logs on they are presented with a Facebook style wall with all of their friends updates, @ mentions, group updates and favorites.

    I changed the following line of code in the activity-loop.php:

    To:

    This basically did what I wanted with 2 exceptions.

    1. I cannot display the users own updates in the activity stream and
    2. This is a global activity change which is affecting my groups activity stream. Basically what is happening is it is only displaying friends activity in the users activity stream and the groups activity stream. I am looking for all group activity to display.

    How can I do this?

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

  • 9087877
    Inactive

    Try my plugin here: https://buddypress.org/community/groups/buddypress-friendpress/ see this is what your after. After installation, and activation go to dashboard/settings/ bp friendpress and change the setting to current user / friends activity. Just be aware it also make buddypress specific pages private so only members can view them. make sure to read the readme.txt regarding group forums or sitewide forums and make changes appropriately. If you do not want the buddypress specific pages private you can go in the bp-friendpress.php file and comment out the part that says “The walled garden.” Hope this helps!


    meg@info
    Participant

    @megainfo

    I think buddypress dont accept multi scope :) just only one scope,

    try this shortcode, it work for me


    /**
    * comparator
    */
    function cmp($a, $b) {
    return strtotime($a->date_recorded) date_recorded);
    }

    /**
    * show friends+groups+mentions actitivity in stream
    */
    function bp_get_interests_activity($atts, $content = null){
    $activities = null;
    if ( is_user_logged_in() ) :
    extract(shortcode_atts(array(
    'max' => '20'
    ), $atts));

    do_action( 'bp_before_activity_loop' );
    global $activities_template;

    //get last friends activity ( default 20)
    bp_has_activities( 'scope=friends' );
    $friends_activities = $activities_template->activities;

    //get last groups activity ( default 20 )
    bp_has_activities( 'scope=groups' );
    $groups_activity = $activities_template->activities;

    //get last mentions ( default 20 )
    bp_has_activities( 'scope=mentions' );
    $mentions_activity = $activities_template->activities;

    $intersting_activity = array_merge($friends_activities, $groups_activity, $mentions_activity);
    usort($intersting_activity, "cmp");

    $activities_template->activities = $intersting_activity;
    $activities_template->activity_count = $max;
    $activities = '
      ';
      ob_start();
      while ( bp_activities() ) : bp_the_activity();
      do_action( 'bp_before_activity_entry' );
      ?>
      <li class="" id="activity-">

      <a href="">









      <a href="" class="view" title="">













      <?php do_action( 'bp_after_activity_entry' );
      endwhile;
      $activities .= ob_get_contents();
      ob_end_clean();
      $activities .='
    ';
    do_action( 'bp_after_activity_loop' );
    endif;
    return $activities;
    }
    add_shortcode('interests', 'bp_get_interests_activity');

    and you can call it with this


    echo do_shortcode('[interests max=20]');

    this code, will join the friends + groups + mentions of the current user.
    the only problem, it not a join from database, because the code do a join with last activiy from each scope ( i mean mybe we lose the chronologic order of some activity).

    hope this help.


    Roger Coathup
    Participant

    @rogercoathup

    You can also look at the original plugin that Shawn has copied his code from: http://wpmu.org/create-a-better-community-experience-with-the-new-buddypress-friends-only-activity-stream-plugin/

    There are also some earlier posts on here about how to achieve this.


    meg@info
    Participant

    @megainfo

    hi @rogercoathup,

    can you share with as, these posts about how to achieve this if you get the link please.

    thanks advance.


    9087877
    Inactive

    That plugin does not work the way @fanoop requested. That plugin only shows friends activity, and not your own. Just to clarify this bp friendpress shows your own and friend only activity and has admin options. Thanks! :-)


    Roger Coathup
    Participant

    @rogercoathup

    @shawn38. @djpaul @hnla @nuprn1 @pollyplummer

    Did you make reference in the plugin to where you took your code from?

    It’s really bad practice to take other developer’s code and not credit them.


    meg@info
    Participant

    @megainfo

    the code i share work like that:

    he extract :
    – the last 20 activity of friends
    – the last 20 activity of groups
    – the last 20 activity of mentions

    – he join all activities in one list
    – order the activities by date
    – he return the $max of activity

    you can personlize the code to get more that 20 activites in each set.


    Roger Coathup
    Participant

    @rogercoathup

    @megainfo – my outline solution from the other threads is:

    “If you have a look in the code for bp_has_activities(), you can
    see how it’s implemented scope searching internally, and then create your own version:

    e.g. for scope=>friends, it builds an array of the friend IDs and sets that array as the user_id element of the filter.

    Therefore, you should be able to do the same in your template — create an array of friend IDs, add the users own ID to the array, and then pass the array as the user ID filter to bp_has_activities().”

    Rich Fuller’s version: http://wpmu.org/create-a-better-community-experience-with-the-new-buddypress-friends-only-activity-stream-plugin/ takes an alternative approach.

    There’s some coding involved, but either of those solutions should help you.


    et
    Participant

    @edertoledo

    @megainfo hello, I tried to use your code but at the time of ordering by date, but does not take into account the date of comments to an activity, you have no idea how I could fix it

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filtering Activity Stream’ is closed to new replies.
Skip to toolbar