[buddypress-trac] [BuddyPress] #2424: wrong group member sql query in BP_Groups_Member::get_all_for_group

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Jun 4 08:34:39 UTC 2010


#2424: wrong group member sql query in BP_Groups_Member::get_all_for_group
----------------------+-----------------------------------------------------
 Reporter:  smurfdev  |       Owner:       
     Type:  defect    |      Status:  new  
 Priority:  normal    |   Milestone:  1.2.5
Component:  Core      |    Keywords:       
----------------------+-----------------------------------------------------
 1/ if xprofile is enabled but no field defined no member will be displayed
 in the group member list ( /groups/group-name/members/ )

 2/ if xprofile is enabled with one field defined, let's say 'town', member
 list will be displayed as the list of group members' towns.

 I suggest replacing lines in bp-groups/bp-groups-classes.php :

 889                     if ( bp_is_active( 'xprofile' ) )
 890                             $members = $wpdb->get_results(
 apply_filters( 'bp_group_members_user_join_filter', $wpdb->prepare(
 "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login,
 u.user_nicename, u.user_email, pd.value as display_name FROM
 {$bp->groups->table_name_members} m, {$wpdb->users} u,
 {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID =
 pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1
 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}",
 $group_id ) ) );
 891                     else
 892                             $members = $wpdb->get_results(
 apply_filters( 'bp_group_members_user_join_filter', $wpdb->prepare(
 "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login,
 u.user_nicename, u.user_email, u.display_name FROM
 {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID =
 m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql}
 {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) ) );

 with :

 $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id,
 m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email,
 if(u.display_name='',u.user_nicename,u.display_name) as display_name FROM
 {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID =
 m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql}
 {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );

-- 
Ticket URL: <http://trac.buddypress.org/ticket/2424>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list