BP Profile Search › Country Select Field
-
AuthorPost
-
Quint
GuestHello,
1. Installed both BP Profile Search and BuddyPress Xprofile Custom Field Types.
2. Added a “Country” field via BuddyBoss > Profiles
3. Added a Search form and attempted to add “Country” as a search field; however, I cannot find it in the dropdown list.Question 1. Are there specific Xprofile field types that won’t show in the dropdown; such as, the Country field?
Question 2. If the Country field should be in the list, could it be used with select2? A typical search could include multiple countries.
Question 3. PODS can extend the User Profile by adding custom fields. However, these fields also do not show in the dropdown. Is your plugin compatible with PODS?
Thank you,
Quintandrea
Plugin AuthorHello Quint,
BP Profile Search can be made compatible with almost any plugin adding user information to BuddyPress, but it doesn’t contain the compatibility code itself, because that requires knowledge of the internals of the other plugin(s).
Additionally, adding all the compatibility codes to BP Profile Search would result in a maintenance nightmare as the other plugins evolve.
For these reasons BP Profile Search offers a simple registration API that other plugins, or even third party developers, can use to achieve compatibility. You can find the documentation here:
https://dontdream.it/bp-profile-search/custom-profile-field-types/
That said, my answers to your questions are:
1. BuddyPress Xprofile Custom Field Types provides compatibility for a few of its custom fields, but unfortunately the Country Selector field is not among them. If interested, you should contact the developers (BuddyDev) or, if you are a programmer, you can write the code yourself.
2. Yes, Select2 could be enabled for that field, after it’s made compatible.
3. Users fields created by Pods can be made compatible as well, but I’m not aware of any work in that direction. Again, if you are interested you could contact the developers, or write the code yourself, but please keep in mind that BP Profile Search also requires BuddyPress, or the BuddyBoss Platform, in order to work.
Quint
GuestHello Andrea,
Thank you for your response.
1. I have contacted Brajesh at BuddyDev and he will do exactly what you recommended for that particular field. Should be completed early next week.
2. Looking forward to that.
3. I will reach out to the PODS folks.
I just submitted another contact form relaying a bug.
Cheers,
Quintandrea
Plugin AuthorGreat, please keep me informed!
Quint
GuestHello Andrea,
Brajesh has recently updated his plugin and the “country” field is now visible in your plugin.
Two observations:
- On the frontend, Country renders as a list of checkboxes. How can this be changed to a multiselect dropdown?
- Choosing a country, United States for example, should at the very least return me. However, no results are found.
Can you take a look?
website: https://pickleballers-draft-1.mystagingwebsite.com/Your credentials should still work since this site a clone.
andrea
Plugin AuthorHello Quint,
I think your Country field now works as you need on your test site.
* I changed ‘set’ to ‘text’ in “BuddyPress Xprofile Custom Field Types”, file class-bp-profile-search-helper.php, line 77;
* Then I chose the “is one of” search mode in your search form;
* Then I added a code snippet to change the list of checkboxes to a multiselect dropdown:
add_action ('bps_field_before_search_form', 'change_display'); add_action ('bp_ps_field_before_search_form', 'change_display'); function change_display ($f) { // field_16 is your Country field if ($f->code == 'field_16' && $f->display == 'checkbox') { $f->display = 'multiselectbox'; } }I used “Code Snippets” to add the snippet, see:
https://pickleballers-draft-1.mystagingwebsite.com/wp-admin/admin.php?page=snippets
but you can move it to bp-custom.php if you prefer.
Quint
GuestHello Andrea,
That works!
I must be blind. I can’t find that php file to which you’re referring in that plugin. I’m having FileZilla search through the entire plugins directory for it. Nothing yet.
P.S. I moved your snippet to WPCodeBox since that’s where I have all my snippets.
FYI: I added BP Distance Search and followed your instructions. I have placed the API key in both the Elementor > Settings > Integration and field I’m using for “City” which is of type Google Place Autocomplete.
However, when I place the cursor in the field, this pops up:
https://www.dropbox.com/s/mwa93ebqt5jxeg3/Screen%20Shot%202022-06-08%20at%206.05.33%20PM.png?dl=0
And in the console, an api target blocked map error is shown:
https://www.dropbox.com/s/4474msqpzzzhcb6/Screen%20Shot%202022-06-08%20at%206.55.06%20PM.png?dl=0
I believe I’ve set the api credentials correctly. Do you see anything that I may be missing here?
https://www.dropbox.com/s/3vtwjlsuccwh8mm/Screen%20Shot%202022-06-08%20at%206.55.28%20PM.png?dl=0
https://www.dropbox.com/s/cl16c1k23jutjon/Screen%20Shot%202022-06-08%20at%207.22.53%20PM.png?dl=0
Quint
andrea
Plugin AuthorHello Quint,
The full path of the file I changed is:
bp-xprofile-custom-field-types/src/filters/class-bp-profile-search-helper.php
Search by distance is working for me on your test site, for instance try searching for Tempe and you’ll get the user from Tempe.
Quint
GuestHello Andrea,
So, clearly I’m blind. Thanks for specifying the path. I’ll let Brajesh know of the edit.
I am no longer getting that error. Two possibilities:
- Time was required for the API to activate?
- You added City to the search form?
Question: In the User Profile, when the entering the “city,” then finding it, and selecting it, the city, state, and country are all rendered in that field. Is there a filter that can process that value to return just the city?
andrea
Plugin AuthorHello Quint,
Probably it was a delay problem. I did add City to the search form, but that’s unrelated to the Google API configuration.
A filter to modify a field value is probably available, but that’s a BuddyPress thing and I don’t have an answer ready. Additionally, I don’t know if changing the value would play well with the Google API.
Quint
GuestHello Andrea,
I spent all day today trying to find what could be done either from the WordPress side or the Google API side. I found nothing.
Then, you’re gonna hate me for this, I found this: https://www.buddyboss.com/product/locations-for-buddypress/
On that page, your plugin is listed. So, I thought I would give their plugin a shot. I installed it. Added the Google API key as instructed. Added my location (City, State, Country) fields to the BuddyBoss > Profiles > Details tab.
Then I navigated to my Profile > Details > Edit and clicked in the new City field and up popped the autocomplete. When Las Vegas came up, I selected it and the following happened: only the “Las Vegas” string was rendered, and the State and Country fields were automatically completed. That is exactly what I wanted from the address fields.
Next while crossing my fingers for luck, I navigated to your form and pointed the Country and City fields to the new fields I created, then went to the Members Directory page. Refreshed the page and the search form fields for Country and City are not the same as the prior working version. No luck.
So, the BuddyBoss plugin hasn’t been updated since 2020, but they still sell it given I just bought it. Do you think it’s an issue on their end? If so, I’ll place a ticket with them.
Cheers,
Quintandrea
Plugin AuthorHello Quint,
I need a copy of ‘Location Autocomplete for BuddyPress’ to see if it’s fully compatible with BP Profile Search.
Could you please lend me your copy for a few days? You can send it to my email address.
-
AuthorPost