BP Profile Search › New version - template and filter
-
AuthorPost
-
Jennifer
GuestHi! I have 2 problems new with the new version, can you help me?
———-First——————–
1. make exact copy of /plugins/bp-profile-search/templates/members/bps-form-default.php and place it in Child-Theme/buddypress/members/new-template.php2. Put this in functions php:
add_filter ('bps_templates', 'add_template'); function add_template ($templates) { $templates[] = 'members/new-template'; return $templates; }and when the option open the option it didnt appear like the template default.
Image: https://prnt.sc/qz77jl—————-Second————
Time before you give me this code for filter for locationadd_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 = 52;"; $value = $wpdb->get_row ($query); if (!empty ($value)) { $filters['field_62_distance']['distance'] = 100; $filters['field_62_distance']['units'] = 'km'; $filters['field_62_distance']['location'] = $value->location; $filters['field_62_distance']['lat'] = $value->lat; $filters['field_62_distance']['lng'] = $value->lng; } return $filters; }is it compatible? because now this filter the user with a different location.
thanks very much!!!
andrea
Plugin AuthorHi Jennifer,
1. Try to lower the priority of your filter, so it runs after the Kleo code.
add_filter ('bps_templates', 'add_template', 20);2. That code is still valid. Please double check the IDs 52 and 62, and the value of the field 52 for the logged-in user. If they are correct, I’ll need more information to understand the issue.
Jennifer
GuestHi Andrea!
1) it works perfectly!
2) I add to the code $bp global.. but i notice that the field 52 was import by a form, so the field only have the complete name but it didnt save the lat and long (table bds_locations appears like 0). so this dont work.
is any way to filter this?
Thanks very much!andrea
Plugin AuthorHi Jennifer,
Which of the following is true in your case?
1. The bds_locations table is completely empty.
2. The bds_locations table is populated, and in all the rows the lat and lng values are 0.
3. The bds_locations table is populated, and in a few rows the lat and lng values are 0.
4. Other – please detail.
Jennifer
GuestHi Andrea!
The case is the number 3. because the value is imported with this function from the form (the form use google of autocomplete but in the bd only save the name of location).
sometimes is full when i complete in the front end on the page for test and use the field with autocomplete.//fragment of code if (function_exists('bp_core_signup_user')) { // Profile fields $usermeta = array( 'field_43' => $form->getValueText('quform_5_44'), ); $usermeta['profile_field_ids'] = '43';Jennifer
Guesthttps://prnt.sc/qzplkq with
var_dump($value);andrea
Plugin AuthorWhen you get the location from a different form, as in your case, you also need to update the bds_locations table with the lat-long values.
Does your form provide the lat-long coordinates too?
Jennifer
GuestThanks Andrea!! I found a way with google api to get lat and long and update the bds_locations table with the lat-long values.. Now it works!!
It would be perfect if the distance would appear likeas the image in the direction.https://prnt.sc/qzxp6x
(When I type the address in the search box manually without applying the php filter it works, but with the filter I only get the results)andrea
Plugin AuthorHi Jennifer,
You’re welcome! Unfortunately at this time it’s not possible to show the distance using a hidden filter. I’m taking a note to study that feature for a future release.
-
AuthorPost