Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to display the Group’s recent activity


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’ );`

Skip to toolbar