diff --git src/bp-groups/bp-groups-classes.php src/bp-groups/bp-groups-classes.php
index c036b62..5bfd2f5 100644
|
|
class BP_Group_Member_Query extends BP_User_Query { |
1702 | 1702 | * @param BP_User_Query $query BP_User_Query object. |
1703 | 1703 | */ |
1704 | 1704 | public function set_orderby( $query ) { |
| 1705 | global $wpdb; |
| 1706 | |
1705 | 1707 | $gm_ids = $this->get_group_member_ids(); |
1706 | 1708 | if ( empty( $gm_ids ) ) { |
1707 | 1709 | $gm_ids = array( 0 ); |
… |
… |
class BP_Group_Member_Query extends BP_User_Query { |
1711 | 1713 | // the order according to the query performed in |
1712 | 1714 | // BP_Group_Member_Query::get_group_members(). Otherwise, fall |
1713 | 1715 | // through and let BP_User_Query do its own ordering. |
1714 | | if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined' ) ) ) { |
| 1716 | if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) { |
| 1717 | |
| 1718 | // Group Activity DESC |
| 1719 | if ( 'group_activity' == $query->query_vars['type'] ) { |
| 1720 | $activity_table = buddypress()->activity->table_name; |
| 1721 | $group_activity_where = array( |
| 1722 | 'user_id IN (' . implode( ',', $gm_ids ) . ')', |
| 1723 | 'item_id = ' . absint( $query->query_vars['group_id'] ), |
| 1724 | "component = 'groups'", |
| 1725 | ); |
| 1726 | $group_activity_where = implode( ' AND ', $group_activity_where ); |
| 1727 | $group_user_ids = $wpdb->get_results( "SELECT user_id, max( date_recorded ) as date_recorded FROM {$activity_table} WHERE {$group_activity_where} GROUP BY user_id ORDER BY date_recorded DESC" ); |
| 1728 | $gm_ids = wp_list_pluck( $group_user_ids, 'user_id' ); |
| 1729 | } |
1715 | 1730 | |
1716 | 1731 | // The first param in the FIELD() clause is the sort column id |
1717 | 1732 | $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); |
diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
index bca272a..d7b752f 100644
|
|
function bp_groups_members_filter() { |
2437 | 2437 | <select id="group_members-order-by"> |
2438 | 2438 | <option value="last_joined"><?php _e( 'Newest', 'buddypress' ); ?></option> |
2439 | 2439 | <option value="first_joined"><?php _e( 'Oldest', 'buddypress' ); ?></option> |
| 2440 | |
| 2441 | <?php if ( bp_is_active( 'activity' ) ) : ?> |
| 2442 | <option value="group_activity"><?php _e( 'Group Activity', 'buddypress' ); ?></option> |
| 2443 | <?php endif; ?> |
| 2444 | |
2440 | 2445 | <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> |
2441 | 2446 | |
2442 | 2447 | <?php do_action( 'bp_groups_members_order_options' ); ?> |