Skip to:
Content
Pages
Categories
Search
Top
Bottom

A Great Little Addition for your Buddypress Site:


  • Virtuali
    Participant

    @gunju2221

    Here is a quick snippet to display the group’s latest activity on the Group’s Directory Page:

    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=&quot;item-desc&quot; id=&quot;activity-">
    <div class="activity-avatar">
    <a href=&quot;">
    
    </a>
    </div>
    <div class="activity-content">
    <div class="activity-header">
    
    </div>
    </div>
    </div>
    <?php endwhile;
    
    }
    add_action( 'bp_directory_groups_item', 'my_group_loop_activity_item' );
    

    Add this to bp-custom.php or functions.php in your theme.

    Although if your group is a private group, the activity will still show up on the page.

    Credits of Etivite for creating this

  • The topic ‘A Great Little Addition for your Buddypress Site:’ is closed to new replies.
Skip to toolbar