Search for PLZ

Home Forums BP Profile Search Forum Search for PLZ

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10511 Reply
    Kasimir
    Guest

    Dear 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.

    #10512 Reply
    andrea
    Keymaster

    Hello 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:

    https://dontdream.it/bp-profile-search/search-modes/

    #10513 Reply
    Kasimir
    Guest

    Hello 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.

    #10514 Reply
    andrea
    Keymaster

    Yes, 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.

    #10515 Reply
    Kasimir
    Guest

    Hello Andrea,

    thank you very much for your excellent and quick support!!

    #10516 Reply
    andrea
    Keymaster

    You’re welcome, and all the best with your site.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Search for PLZ
Your information: