0

I have a form that passes information such as 'name', 'email', 'orderno', 'amount' and 'note' to a payment form hosted at ePay.

In order to pass the field-values I use the standard-confirmation on the form with a type of redirect. I then pass the values in the query string. All is fine, except for one small problem: The query-string includes a callback parameter, which has it's own query-string (including 'note'). In order to make this work I have urlencoded the callback-url, and if I set a static single-word value for the note-parameter it works. However if I insert the field value from 'note' it fails (my guess is, due to spaces etc.).

So what I need to accomplish is to urlencode the value from the 'note'-field before it is being inserted into the query-string. But I have no idea how to do that.

This is what the query-string for the confirmation redirect looks like with a static single-word value in 'note' (this will work):

https://example.com/payment?merchantnumber=999999&currency=208&amount={:5}&orderid={:3}&language=0&callbackurl=https%3A%2F%2Fexample.com%2Fepay.ashx%3Fnote%3Dsingleword

This is what it will look like with the value from 'note' as paragraph text (this will not work):

https://example.com/payment?merchantnumber=999999&currency=208&amount={:5}&orderid={:3}&language=0&callbackurl=https%3A%2F%2Fexample.com%2Fepay.ashx%3Fnote%3Dlorem+ipsum+dolor+sit+amet

This is what I'm trying to accomplish (this should work):

https://example.com/payment?merchantnumber=999999&currency=208&amount={:5}&orderid={:3}&language=0&callbackurl=https%3A%2F%2Fexample.com%2Fepay.ashx%3Fnote%3Dlorem%20ipsum%20dolor%20sit%20amet

I hope everything makes sense, and that someone can guide me in the right direction.

Thanks.

0

After digging a little deeper, I found that there is an action hook in Gravity Forms called gform_pre_submission. This allows me to modify a posted value before creating an entry or running the confirmation (see documentation).

After that it was pretty basic:

add_action( 'gform_pre_submission_11', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
    $_POST['input_7'] = urlencode(rgpost( 'input_7' ));
}

This targets form ID 11 and replaces field 7 with an urlencoded version of field 7.

Job done :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.