Own xProfile Fields as default values in the search form

Home Forums BP Profile Search Forum Own xProfile Fields as default values in the search form

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10320 Reply
    Jennifer
    Guest

    Hi Andrea, I have managed to establish locations in different fields of xprofile
    I have been reading and with the second function I could use a field to search for several.
    How can I join it to the first one?

    that is to say that the search field is autocomplete by default with an xprofile (46 and 47) and that same search in this? Thank you so much for all your help!maybe something i’m doing wrong that doesn’t work like before

    //filter for location adress
    add_filter ('bps_hidden_filters', 'directory_filters');
    function directory_filters ($filters)
    {
    	global $wpdb;
    
    	$user = bp_loggedin_user_id ();
    	if (empty ($user))  return $filters;
    
    	$table_name = $wpdb->prefix. 'bds_locations';
    	$query = "SELECT * FROM $table_name WHERE user_id = $user AND field_id = 53;";
    	$value = $wpdb->get_row ($query);
    
    	if (!empty ($value))
    	{
    		$filters['field_46_distance']['distance'] = 30;
    		$filters['field_46_distance']['units'] = 'km';
    		$filters['field_46_distance']['location'] = $value->location;
    		$filters['field_46_distance']['lat'] = $value->lat;
    		$filters['field_46_distance']['lng'] = $value->lng;
    	}
    
    	return $filters;
    }
    
    add_filter ('bps_field_sql', 'change_query', 10, 2);
    function change_query ($sql, $f)
    {
            if ($f->id == 46) 
              $sql['where']['field_id'] = 'field_id IN (99,103,104,105,106,107,108,109,110,111)';
            return $sql;
    }
    #10321 Reply
    andrea
    Keymaster

    Hi Jennifer,

    BP Profile Search can use a search field only once. So if you use field 46 as a hidden filter with your first function, you cannot use the same field a second time.

    Therefore your second function, which again involves field 46, will be ignored or, worse still, the plugin will not work properly.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Own xProfile Fields as default values in the search form
Your information: