Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display activity of a specific group

  • @aido141176

    Participant

    I would like to display activity of a specific group on a curtain page. I am finding that I can only view some groups activities but not others.

    For example:

    This will work to some degree as it only shows when the group was created:
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . "&primary_id=2" ) ) : ?>

    But this want work at all and displays nothing:

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . "&primary_id=3" ) ) : ?>

    The groups have identical settings.

    I even tried to use a shortcode plugin to see if that changes things:

    BuddyPress Activity Shortcode

    But using the shortcode plugin the same issue occurs..

    This will work to some degree as it only shows when the group was created:
    [activity-stream object=groups primary_id=2]

    But this want work at all and displays nothing:
    [activity-stream object=groups primary_id=3]

    This has got me baffled, I even did a dump of all data from all groups to see if there were differences, but there were none I could see.

    Any one who could help me with this I would appreciate very much

Viewing 5 replies - 1 through 5 (of 5 total)
  • @danbp

    Participant

    Hi,

    you have to use a group_id and to ensure you’re in an appropriate loop (activity or group)

    To get a group id, you can for ex. do:

    // check for a group ID
    	if( bp_has_groups() ) {
    		// Grab current group ID
    		bp_the_group();
    		$group_id = bp_get_group_ID();
    	}	
    	
        // apply our changes only to this group ID's
    	// conditionnal action
    	if ( $group_id == 22 OR $group_id == 8 ) {  

    … and so on!

    You may also use bp_parse_args, depending where you use your custom work. In other words, you can create a complete new activity loop on a distinct page template for only one group.

    Using bp_parse_args() to filter BuddyPress template loops

    @aido141176

    Participant

    Hi danbp, thank you for your response. Unfortunately I’m not sure how I can get this to work.

    Can you please show me a loop that will show all activity for say a group with ID 2. Or even with a slug, say ‘group_slug’.

    Here is the loop I am using:

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . "&primary_id=2" ) ) : ?>
    
    <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
            <?php locate_template( array( 'buddypress/activity/entry.php' ), true, false ); ?>
     
        <?php endwhile; ?>
    <?php endif; ?>

    I tried both to incorporate your code into the activity loop but it didn’t work.

    I want display this activty not on a buddypress page. I want it to go on homepage. I can already get the group ID I just want to be able to make a loop that displays the activity of a curtain groupusing the group ID.

    If you could show me a whole complete loop that would work I would be really greatful.

    Thanks

    @aido141176

    Participant

    Does anyone really know how to do this?

    @danbp

    Participant

    Did you read the related documentation ? Specially the one related to the groups-loop ?

    Groups Loop

    My previous answer contained a solution to do that programmatically. But you (continue to) use the template method. If you want this method, see the mentionned groups-loop.

    @aido141176

    Participant

    I want to list the activity for a specific group, not list of groups. I have not continued withe template method danbp. I’ve tried everything you mentioned including the bp_parse_args(). I just couldn’t get it to work. I could get it change the amount of list items but not display a selected group activity.

    But I have gone back to using the activity loop now, trying to incorporate the code you gave me.

    Here is the activity loop, how would you incorporate your code above:

    <?php if ( bp_has_groups() ) : ?>
     
        <div class="pagination">
     
            <div class="pag-count" id="group-dir-count">
                <?php bp_groups_pagination_count() ?>
            </div>
     
            <div class="pagination-links" id="group-dir-pag">
                <?php bp_groups_pagination_links() ?>
            </div>
     
        </div>
     
        <ul id="groups-list" class="item-list">
        <?php while ( bp_groups() ) : bp_the_group(); ?>
     
            <li>
                <div class="item-avatar">
                    <a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ) ?></a>
                </div>
     
                <div class="item">
                    <div class="item-title"><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></div>
                    <div class="item-meta"><span class="activity"><?php printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() ) ?></span></div>
     
                    <div class="item-desc"><?php bp_group_description_excerpt() ?></div>
     
                    <?php do_action( 'bp_directory_groups_item' ) ?>
                </div>
     
                <div class="action">
                    <?php bp_group_join_button() ?>
     
                    <div class="meta">
                        <?php bp_group_type() ?> / <?php bp_group_member_count() ?>
                    </div>
     
                    <?php do_action( 'bp_directory_groups_actions' ) ?>
                </div>
     
                <div class="clear"></div>
            </li>
     
        <?php endwhile; ?>
        </ul>
     
        <?php do_action( 'bp_after_groups_loop' ) ?>
     
    <?php else: ?>
     
        <div id="message" class="info">
            <p><?php _e( 'There were no groups found.', 'buddypress' ) ?></p>
        </div>
     
    <?php endif; ?>

    I’m sorry if this is annoying you, I do appreciate your help. I’ve only been working with buddypress for about a week.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar