Skip Navigation

[Resolved] Save cred form redirection

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by mikeH-3 5 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1298181

When I edit a post on my frontend using a cred form, the url of that page ends up being something like:

hidden link

When I click the save button to save the post, it takes me back to the item to view it normally, but the whole page url structure of that post is different. It turns into something like hidden link

Is there a function I can use so that it redirects back to the same post, using the url it was at? So when I save the post, it goes back to hidden link

This is very important to get working so that the whole system works properly.

Thanks! Mike

#1298225

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset Forms offers the redirection hook <Strong>cred_success_redirect
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

Can you please try this hook to redirect the user to your desired page.

As well as, What if you try to change the form settings "After visitors submit this form:" and set it to "Keep Displaying this form" if that works you do not need to use the hook "cred_success_redirect".

#1298719

Thanks. So how do I edit this function properly for the RETURN field? I am trying to get shortcode values in there basically.

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==26)
        return '<em><u>hidden link</u></em> param='church']&sermonid=[wpv-post-id format="meta" meta="ID"]';
   
    return $url;
}

I must have wrong syntax for the return field because it keeps crashing the site.

#1299101

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can use the PHP global variable $_GET to catch the value of the URL param.

Can you please try to use the following code and try to resolve your issue.

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data){

if ($form_data['id']==26) {
        return '<em><u>hidden link</u></em>'.$_GET['church'].'&sermonid='.$post_id;
}
    
    return $url;
}
#1299103

Yes that worked. I have an issue though. I also had this in my functions.php:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data) {
        // if a specific form
        if ($form_data["id"]==1625 && isset( $_POST['continue'] ) )        
        return '/';
        return $url;
    }

and when I add your code, it obviously breaks the site since both function names are the same. When I change the function names, the site comes back up, but then the code you just sent stops working. Basically this code I'm enclosing in this post already existed in my functions file allowed me to make a 'save & continue' button that stays on the page after you save. I'd like to keep that too.

Thanks much!

#1299105

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As you can see with the following code I've merged the both code as given under. Can you please try that and try to resolve your issue.

add_filter('cred_success_redirect', 'func_custom_redirect',10,3);
function func_custom_redirect($url, $post_id, $form_data){
 
if ($form_data['id']==26) {
        return '<em><u>hidden link</u></em>'.$_GET['church'].'&sermonid='.$post_id;
}

 if ($form_data["id"]==1625 && isset( $_POST['continue'] ) )  {
        return '/';
 }
    return $url;
}
#1299107

My issue is resolved now. Thank you!