Created
May 10, 2021 13:34
-
-
Save wbcomdev/e216ac7577594dd7c0180ae57d071eb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Display recently active group members tab in single group page. | |
| */ | |
| function wb_recently_active_group_member_tab() { | |
| global $bp; | |
| $user_access = false; | |
| $group_link = ''; | |
| if ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) ) { | |
| $group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/'; | |
| $user_access = $bp->groups->current_group->user_has_access; | |
| bp_core_new_subnav_item( | |
| array( | |
| 'name' => __( 'Recently Active', 'Recently Active' ), | |
| 'slug' => 'recently-active', | |
| 'parent_url' => $group_link, | |
| 'parent_slug' => $bp->groups->current_group->slug, | |
| 'screen_function' => 'wb_bp_recently_group_member_screen', | |
| 'position' => 50, | |
| 'user_has_access' => $user_access, | |
| 'item_css_id' => 'wb-recently-group-member-active', | |
| ) | |
| ); | |
| } | |
| } | |
| add_action( 'bp_init', 'wb_recently_active_group_member_tab' ); | |
| /** | |
| * Recently group members screened functions. | |
| */ | |
| function wb_bp_recently_group_member_screen() { | |
| add_action( 'bp_template_content', 'wb_recently_active_group_members_active_tab_content' ); | |
| // add the filter | |
| add_filter( 'bp_core_get_active_member_count', 'filter_bp_core_get_active_member_count', 10, 1 ); | |
| $templates = array( 'groups/single/plugins.php', 'plugin-template.php' ); | |
| if ( strstr( locate_template( $templates ), 'groups/single/plugins.php' ) ) { | |
| bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) ); | |
| } else { | |
| bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); | |
| } | |
| } | |
| /** | |
| * Display recently active members in buddypress groups. | |
| * | |
| * @return void | |
| */ | |
| function wb_recently_active_group_members_active_tab_content() { | |
| $user_id = get_current_user_id(); | |
| $members_args = array( | |
| 'user_id' => $user_id, | |
| 'type' => 'active', | |
| 'populate_extras' => true, | |
| 'search_terms' => false, | |
| ); | |
| if ( bp_group_has_members( $members_args ) ) : | |
| ?> | |
| <div id="member-count" class="pag-count"> | |
| <?php bp_group_member_pagination_count(); ?> | |
| </div> | |
| <div id='member-pagination' class='pagination-links'> | |
| <?php bp_group_member_pagination(); ?> | |
| </div> | |
| <ul id="member-list" class="item-list"> | |
| <?php | |
| while ( bp_group_members( $members_args ) ) : | |
| bp_group_the_member( $members_args ); | |
| ?> | |
| <li> | |
| <div class="item-avatar"> | |
| <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> | |
| <?php bp_group_member_link(); ?> | |
| </div> | |
| <!-- Example template tags you can use --> | |
| <div class="item-meta"><span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php echo bp_get_member_last_active( $args ); ?></span></div> | |
| </li> | |
| <?php endwhile; ?> | |
| </ul> | |
| <?php else : ?> | |
| <div class="no-recently-active-members"> | |
| <?php esc_html_e( 'There are no recently active members', 'buddypress' ); ?> | |
| </div> | |
| <?php | |
| endif; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment