Tell us what you are trying to do?
hey there, the title says it all. i need a simple page refresh after a form is submitted. or another solution to redirect to a custom url.
the options in the forms wizzard don´t have these options. (screenshot)
hope you can help me. i haven´t found any solutions in the forum.
cheers
Hello,
I assume you are going to redirect user to some URL outsider the WordPress.
If it is, please try the filter hook "cred_success_redirect", see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
Hey Luo,
the credhook is working. But i do have i problem because of the url attribute.
I need the redirect to the main url without
the parameter behind it
versteckter Link
Just need versteckter Link
Can we solve this with a javascript function maybe?
Thanks for your help
For the new question:
Can we solve this with a javascript function maybe?
Unfortunate, since the the redirection is set in server side, so it can not be changed with javascript function, and the URL parameter "cred_referrer_form_id" is required to display form message, so there isn't any option to remove it.
Hey Luo,
Thanks for your answer. I just checked the cred api. Maybe a walkourand would be possible with the cred_submit_complete function.
Maybe why can trigger here just a page refresh?
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==12)
{
// user can overwrite everything here, eg redirection, messages displayed etc..
// eg redirect regardless of form settings
header('location:success.php');
}
}
//Custom success action can also be performed for a specific form by using the form ID:
add_action('cred_submit_complete_12', 'success_for_form_with_id_12',10,2);
function success_for_form_with_id_12($post_id, $form_data)
{
//some code here
}
Sorry but i am a beginner to javascript but is it possible to trigger this
"document.location.reload(true)"
with the cred api?
There is a simple workaround, you can try these:
1) Create a new wordpress page "my redirect endpoint", for example, page ID is 123
2) Edit your form, in the screenshot you mentioned above:
https://toolset.com/wp-content/uploads/2019/09/1332071-Bildschirmfoto_2019_09_05_um_08.00.02.png
Choose below options:
After visitors submit this form-> Go to a page...-> my redirect endpoint
So after user submit the form, it should be redirect to page "my redirect endpoint"
3) Modify the custom PHP codes as below, when user enter the page "my redirect endpoint", redirect him to the specific URL, for example:
add_action( 'template_redirect', function(){
if(get_the_ID() == 123){
header('Location: <em><u>versteckter Link</u></em>');
exit;
}
} );
More help:
https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
Hey luo, thanks for you help.
This workaround does work. But i noticed that it takes much more time with the redirect to another page and then redirect back.
Can‘t we use one of the cred apis to test if there is a better solution?
Maybe manipulate the url with the cred_form_action_uri_querystring_array
or the cred_submit_complete to overwrite the redirect and go direct to the home url.
Have a great start to the week
Cheers
Yes, you are right, it is possible with action hook "cred_submit_complete" too, for example:
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==123)
{
// user can overwrite everything here, eg redirection, messages displayed etc..
// eg redirect regardless of form settings
header('location:success.php');
exit;
}
}
Please replace 123 with your post form's ID
But it won't work if you use option "Submit this form without reloading the page (use AJAX)".
My issue is resolved now. Thank you!