I think so. It should be part of the array $form_data, but that's undocumented. So, you will need to investigate it a bit and find out what data is in there. Note that a form is just a post, you can check its custom field to find out where that redirect page is stored and use it. Or you can just hardcode it in the custom code.
What if you try to use the WordPress function get_permalink() to get the link of the page based on the ID.
For example:
// Decide here where to redirect
$red_id = 4547; // your page ID where you want to redirect
$redirect_url = get_permalink($red_id);
wp_redirect( $redirect_url );
exit;
Yes, I could do that, but then I could also hardcode the permalink.
I was trying to extract the redirection from the form settings, so I could use the same function for different forms.
Otherwise, I will have to duplicate the function for every form or use a IF/ELSE chain, as every form have a different redirection's page.
Now the only problem is that the form notification won't be sent, if the user exist.
Is it possible to "force" sending it?
As the user form won't be saved, I think we would need some way to trig the notification from the function.
Now the only problem is that the form notification won't be sent, if the user exist.
Is it possible to "force" sending it?
==>
Toolset email notification works when the form is successfully submitted.
I do not think or never seen ever that if you try to register and user is not available, only error message is displayed. I never seen that email is sent when you validate the user. Even if you check sites like facebook etc..etc.. you will see that validating user it will display only error message, it will not send email.
I think you may misunderstand the workflow of this form.
The form is used on single properties of a real estate site.
When a customer is interested on a particular property, he fills and submit the form, containing name and email fields.
At this point different things could happen:
- The user doesn't exist
In this case the user it's created and a custom post "inquiry" is added.
This inquiry post contains the property's object ID, number of rooms, price, etc. and this new user assigned as author.
The admin receives then a notification, triggered from the form submission, that a new inquiry and user has been added.
- The user exist
It can happen that a customer, which is already registered, it's interested on another property.
He fills the form again and submit.
At this point, we cannot add the user because it generates a "user exist" error, BUT we need anyway to create the new inquiry post and assign it to this user.
And even if the user it's not created, admin needs to know that a new inquiry post has been added.
But sadly the notification won't be sent because of the "user exist" error.
- The user exist
It can happen that a customer, which is already registered, it's interested on another property.
He fills the form again and submit.
At this point, we cannot add the user because it generates a "user exist" error, BUT we need anyway to create the new inquiry post and assign it to this user.
And even if the user it's not created, admin needs to know that a new inquiry post has been added.
But sadly the notification won't be sent because of the "user exist" error.
==>
Yes, because form is not going to submit due to duplicate user error returned by validation hook.
You can chose either to display error or you have to remove the validation hook and but removing validation hook will also not help as there will be no duplicate users.
You have to set a flow that if duplicate user found - you should redirect user to login page or try auto login and create a post and send notification using wp_mail() function as form is not going to submit, form notification is not going to trigger.