• Resolved resident82

    (@resident82)


    Is it possible to override the field value for the search field when the search button is clicked?

    I found how to do this for any fields in the login form using pdb-before_submit_signup

    function newValue( $fields ) {
        $fields['myField'] = "111";
        return $fields;
    }
    
    add_filter( 'pdb-before_submit_signup', 'newValue' );

    but I don’t understand how to do this for the search field

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author xnau webdesign

    (@xnau)

    OK, why do you want to do this? If we start there, maybe I can help.

    Thread Starter resident82

    (@resident82)

    I use the plugin as a car database and added a search field to the site by car number. But the same number can be written the same way by cyrillic and latin symbols, for example ВА1234АА and BA1234AA and as a result they are searched separately. My plan is to overrite user input to one encoding when writing to the database and when searching.

    Plugin Author xnau webdesign

    (@xnau)

    OK, that make sense. The list search submission isn’t processed in the same way as a database form submission so you can’t alter it in the same way.

    Instead, you need to alter the database query directly, and this is a bit trickier because you need to use regular expressions to grab the input value, convert it and put it back into the query.

    This is done using the pdb-list_query filter that gives you a way to alter it directly.

    Thread Starter resident82

    (@resident82)

    Thanks for response. I’ve been wanting to understand regular expressions for a long time.

    Plugin Author xnau webdesign

    (@xnau)

    A very helpful site for regular expressions is https://regex101.com/ it gives you a way to test your regexes and explains how they work.

    Thread Starter resident82

    (@resident82)

    It worked, thanks again for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Override the field value for the search field when the search button is clicked’ is closed to new replies.