Skip to content

Instantly share code, notes, and snippets.

@ckchaudhary
Created July 3, 2015 08:23
Show Gist options
  • Select an option

  • Save ckchaudhary/751e32c10aca4c88e16c to your computer and use it in GitHub Desktop.

Select an option

Save ckchaudhary/751e32c10aca4c88e16c to your computer and use it in GitHub Desktop.

Revisions

  1. ckchaudhary created this gist Jul 3, 2015.
    42 changes: 42 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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;
    }