BP Profile Search › Search for PLZ
-
AuthorPost
-
Kasimir
GuestDear Andrea,
thank you for this really flexible plugin.
I have a question about the “Search modes” and how to maybe change them in a bit.
What i like to do:
I create a field in my members profiles called “PLZ”. It is a text field and contains the german “Postleitzahl” like “12345”.I have no problem to address and search the field with your plugin. But i would like to generate results like:
– a search for “1” should only display members with the “PLZ” starting with “1” and not containing “1”.
– a search for “12” should only display members with the “PLZ” starting with “12” and not containing “12”.Example:
My members “PLZ” is “23313”.– searching for “23” should display the member as a result.
– searching for “31” should not display this member but members with “PLZ” like “31…”I hope you understand what i would like to do.
Thank you for taking a look at this.
andrea
Plugin AuthorHello Kasimir,
You can select the search mode is like.
To search for all the numbers that begin with 23, enter 23% in your search field (the % sign matches any number of characters).
You can find more information here:
Kasimir
GuestHello Andrea,
thank you very much for your quick reply. It works!
There is one more thing i would like to do and maybe you could tell me where i have to do that.
I don’t want to explain to the users that they have to put the “%”-sign at the end of their search entry. So i would like to hardcode the “%”-sign in a template file or wherever so that it is added automatically even if the user only entries “23” in the search field.
I have only one search field so it doesn’t matter what maybe happens to other fields.
andrea
Plugin AuthorYes, you can add this code to your bp-custom.php file:
add_action ('bps_field_before_query', 'append_percent_sign'); function append_percent_sign ($f) { if ($f->code == 'field_32') { $f->value .= '%'; } }Replace 32 with the actual ID of your field.
Kasimir
GuestHello Andrea,
thank you very much for your excellent and quick support!!
andrea
Plugin AuthorYou’re welcome, and all the best with your site.
-
AuthorPost