With regard to the point in the final paragraph – when you sort the members list alphabetically, and then use the search facility, the SQL query looks like:
SELECT COUNT(DISTINCT u.ID) FROM wp_users u LEFT JOIN wp_usermeta um ON um.user_id = u.ID LEFT JOIN wp_bp_xprofile_data pd ON u.ID = pd.user_id WHERE u.user_status = 0 AND (pd.field_id = 1) AND pd.value LIKE ‘%%searchterm%%’ ORDER BY pd.value ASC;
It assumes pd.field_id = 1, which is the Name field – why does it assume you only care about searching on the Name field when ordering alphabetically? And how would I best modify this to search on a) the text values of all my text profile fields, and b) the labels on multiple option profile fields?