Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display the Group’s recent activity

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

  • Virtuali
    Participant

    @gunju2221

    This only works on the group-loop (group index), you could probably hook it into others as well.

    Put in bp-custom

    `function my_group_loop_activity_item() {
    global $bp, $activities_template;

    if ( !bp_is_active( ‘activity’ ) )
    return;

    if ( !bp_group_is_visible() )
    return;

    $show_hidden = false;

    /* Group filtering */
    $object = $bp->groups->id;
    $primary_id = bp_get_group_id();

    if ( ‘public’ != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, bp_get_group_id() ) )
    $show_hidden = true;

    /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
    $defaults = array(
    ‘display_comments’ => false, // false for none, stream/threaded – show comments in the stream or threaded under items
    ‘sort’ => ‘DESC’, // sort DESC or ASC
    ‘page’ => 1, // which page to load
    ‘per_page’ => false, // number of items per page
    ‘max’ => 2, // max number to return
    ‘include’ => false, // pass an activity_id or string of ID’s comma separated
    ‘show_hidden’ => $show_hidden, // Show activity items that are hidden site-wide?

    /* Filtering */
    ‘object’ => $object, // object to filter on e.g. groups, profile, status, friends
    ‘primary_id’ => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    ‘action’ => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
    ‘secondary_id’ => false, // secondary object ID to filter on e.g. a post_id

    /* Searching */
    ‘search_terms’ => false // specify terms to search on
    );

    $r = wp_parse_args( $args, $defaults );
    extract( $r );

    $filter = array( ‘user_id’ => false, ‘object’ => $object, ‘action’ => $action, ‘primary_id’ => $primary_id, ‘secondary_id’ => $secondary_id );

    $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );

    while ( bp_activities() ) : bp_the_activity(); ?>
    <div class="item-desc" id="activity-“>

    <a href="”>

    <?php endwhile;

    }
    add_action( ‘bp_directory_groups_item’, ‘my_group_loop_activity_item’ );`


    andhix
    Participant

    @andhix

    ok thanks…
    Of course, it works on the group-loop,. but how to display on index.php or frontpage?


    r-a-y
    Keymaster

    @r-a-y

    Use the activity loop:
    https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/

    Set parameters to:
    object – groups
    primary_id – $group_id (you need to grab the group id and put it in)
    action – activity_update
    max – 1 (or how many updates you want to return)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to display the Group’s recent activity’ is closed to new replies.
Skip to toolbar