Passing % in Confirmation Redirect Querystring? [RESOLVED]

Hello folks,

First post: I’m hoping someone more GF knowledgeable can point me in the right direction to solve an issue that’s cropped up.

I have a simple form that takes an input text string to search a database table of movies for that string to be part of the movie’s title. It then passes that input using a confirmation redirect in a querystring to a page that uses the WP Data Access plugin to display the results. The querystring takes the form ?wpda_search_column_Title=%Potter% : the result of that is it searches the database using a SQL SELECT… WHERE Title LIKE ‘%Potter%.

All was working fine until recently. However in the latest WPDA release they improved their security (it now uses decodeURIComponent and thus requires the % sign to be encoded as the escaped %25). So I went to my form and tried to change the querystring to replace the ‘%’s with ‘%25’s. But GF rejects that formatting with a message “The text you have entered is not valid. For security reasons, some characters are not allowed”.

Ironically this means the combined efforts of GF and WPDA to maintain security have resulted in them no longer playing nice together. I’d say neither party is wrong in what they are doing but the end result is an incompatibility.

I am speaking to the WPDA development team as well as GF to see if a solution can be devised. My question to the GF end is if anyone can suggest a way to pass a %25 in a querystring?

You can view the form in question at https://movies.blewis.com.au (note there are four forms on the page, Title Search is the simplest hence my using that as the example).

Thanks in Advance for all suggestions.
Regards, Graham

You can run your own PHP code to customize the query string using the following filter: https://docs.gravityforms.com/gform_confirmation/

2 Likes

Hi Samuel,
I hoped something like that would be possible. I’ve read the article about gform_confirmation but am still unclear how to proceed; the only reference to a querystring refers to a multi-select filed which I am not using. Am I right in assuming that the existing redirect string will be available in the $confirmation variable, starting “redirect =>” and then I’ll need to replace all occurrences of ‘%’ with ‘%25’ in the remainder of the string and return that adjusted value? I don’t know PHP at all well so any assistance in that will be appreciated.
Thanks, Graham

Just in case anyone stumbles across this, the answer is simply:

// This will replace the % characters in the querystring being passed to WPDA with %25 as it requires

add_filter( 'gform_confirmation', function ( $confirmation, $form, $entry ) {
    $confirmation = str_replace ('%', '%25', $confirmation);
        return $confirmation;
}, 11, 3 );
1 Like