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.
Checked the source code
hidden link
So this should work, but sadly it doesn't
// Decide here where to redirect
$red_id = $form_data['action_page'];
$redirect_url = site_url() . "/?page_id=" . $red_id[0];
wp_redirect( $redirect_url );
exit;
Any idea? Thanks
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Jamal passed this ticket to me.
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.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please tell me under what hook you want to add that redirection code you shared?
That works great! Thanks.
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.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
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.
However - if you still want to send email, you may try to use the standard WordPress function: wp_mail()
- https://developer.wordpress.org/reference/functions/wp_mail/
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.
Does that make sense now?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
- 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.
This is your custom flow and not how
My issue is resolved now. Thank you!