I've got my member listings and search working really well, I just need to order the members by the custom field company_name, I've tried several things and just can't get it to work! This is my code:
- Code: Select all
$users = $wpdb->get_results ("SELECT DISTINCT(U.user_id) as `ID`
FROM " . $wpdb->usermeta . " AS U
inner join " . $wpdb->usermeta . " as UMF on U.user_id = UMF.user_id
inner join " . $wpdb->usermeta . " as UMS on U.user_id = UMS.user_id
inner join " . $wpdb->usermeta . " as UML on U.user_id = UML.user_id
WHERE UMF.meta_key = '" . $wpdb->prefix . "s2member_custom_fields'
AND UMF.meta_value REGEXP '.*\"".display."\";s:[0-9]+:\"".Yes."\".*'
AND UML.meta_key = '" . $wpdb->prefix . "capabilities'
AND UML.meta_value REGEXP '.*\"".s2member_level1."\";s:[0-9]+:\""."1"."\".*'
LIMIT ".$start.", ".$limit."");
Any suggestions are gratefully received!

Zoe