Skip Navigation

[Resolved] Redirect To Parent Post upon submission of child post edit form

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm trying to find the code to use with "Code Snippets" plugin that will redirect a user to the parent post upon submission of the child post edit form.

Solution:

I suggest you try the filter hook cred_success_redirect, for example:

https://toolset.com/forums/topic/redirect-to-parent-post-upon-submission-of-child-post-edit-form/#post-1169394

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

This support ticket is created 6 years, 2 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1168924

Tell us what you are trying to do?
I've got a parent post type (slug is "bb"). I have child posts created with fields and view with group id "206766" that is displayed within the parent post using a content template. I have a post edit cred form for editing the child post (id is "207109").
I'm trying to find the code to use with "Code Snippets" plugin that will redirect a user to the parent post upon submission of the child post edit form.

Is there any documentation that you are following?
I can't seem to find any docs that are detailed enough for this task

What is the link to your site?
hidden link

Thanks in advance for your help with this.
Wayne

#1169394

Dear Wayne,

I suggest you try the filter hook cred_success_redirect, for example:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==123)
        $bb_post = toolset_get_related_post($post_id, array( 'bb', 'CHILD-POST-TYPE-SLUG' ));
        $bb_post_url = get_permalink($bb_post);
        return $bb_post_url ;
    return $url;
}

Please replace 123 with your Toolset form ID, and replace CHILD-POST-TYPE-SLUG with the child post type slug.

More help:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
https://developer.wordpress.org/reference/functions/get_permalink/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

#1169918

My issue is resolved now. Thank you!

#1170063

You are welcome