Hi,
I have a single line text form that allows a user to enter a number. I need that form to submit to an external url and add the entry from my form to the url of where I’m submitting to.
Hi Alan. In that case, don’t check the box to use the query string, and enter your URL and the merge tags for your field values (like {Number:1}) in the redirect URL area. That will send the data to your URL with the number appended and no question mark. Like this:
I actually tried that but it didn’t quite work either. The url I’m redirecting to has a # in it and it’s causing what you’ll see below. Didn’t mention the # in my original post as didn’t realise it’d be relevant.
Redirect url in settings: https://site[dot]com/#/{Number:1}
Resulting url of the redirect: https://site[dot]com/?#/12345
Hi Alan. I took a look at your simple form and I can see what you mean. I think the # is messing with things. That’s OK though - we can work around it. Please try this code:
<?php
add_filter( 'gform_confirmation', 'custom_confirmation', 10, 4 );
function custom_confirmation( $confirmation, $form, $entry, $ajax ) {
// apply to form 82 only
if( $form['id'] == '82' ) {
$url = 'https://xbulk.no/#/' . rgar ( $entry, '1' );
$confirmation = array( 'redirect' => $url );
}
// return the confirmation either way, modified or not
return $confirmation;
}
That code will apply to form 82. Change 82 in the code to your form ID. If you need to apply this to more forms or all forms, let me know and we’ll work out how to do that.
This is PHP code which can go into your theme functions.php file or a custom functionality plugin if you are using one, or you can use a plugin like this to separate the code from the theme: