Created
July 3, 2015 08:23
-
-
Save ckchaudhary/751e32c10aca4c88e16c to your computer and use it in GitHub Desktop.
Geo my wp - member locator - include other members
This file contains 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
add_filter( 'gmw_fl_after_query_clauses', 'wdw_gmw_fl_qc_alter', 11, 2 ); | |
/** | |
* Geo my wp - member locator addon. | |
* By default the plugin excludes all the users who have not provided their location info yet. | |
* This is bad. If i am not searching by location, but searching only by xprofile fields, | |
* the plugin still excludes users who have not entered their location info yet. | |
* | |
* This is a dirty hack to attemtp to fix that. | |
* | |
* @author ckchaudhary <[email protected]> | |
* | |
* @global type $wpdb | |
* @param array $clauses | |
* @param array $form | |
* @return array | |
*/ | |
function wdw_gmw_fl_qc_alter( $clauses, $form ){ | |
//if no address search | |
if ( empty($form['org_address'] ) ) { | |
$query_from = $clauses['wp_user_query']['query_from']; | |
$query_from = str_replace( "INNER JOIN", "LEFT JOIN", $query_from ); | |
$clauses['wp_user_query']['query_from'] = $query_from; | |
if( trim( $clauses['bp_user_query']['where'] ) == '' ){ | |
/* | |
$query_from = $clauses['wp_user_query']['query_from']; | |
$query_from = str_replace( "INNER JOIN", "LEFT JOIN", $query_from ); | |
$clauses['wp_user_query']['query_from'] = $query_from; | |
*/ | |
} | |
global $wpdb; | |
$clauses['bp_user_query']['select'] = str_replace( "gmwlocations.member_id", "ID", $clauses['bp_user_query']['select'] ); | |
$clauses['bp_user_query']['where'] = str_replace( "gmwlocations.member_id", "ID", $clauses['bp_user_query']['where'] ); | |
$clauses['bp_user_query']['from'] = str_replace( "wppl_friends_locator gmwlocations", $wpdb->users, $clauses['bp_user_query']['from'] ); | |
//$clauses['wp_user_query']['query_fields'] = " "; | |
//$clauses['wp_user_query']['query_from'] = " "; | |
} | |
return $clauses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment