Tell us what you are trying to do?
When user visits an event, there'll be a link ( [cred_child_link_form] ) which takes them to a form where they can add additional information to that event. After successful submission, the user is redirected to the original parent event, where they can again find the [cred_child_link_form] link and again submit further information about the event (another date, another description, etc).
Is there any documentation that you are following?
--- https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect. I tested using the example in this doc, and this works....
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==46)
return 'hidden link';
return $url;
}
--- https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected - this is exactly what I want, and it works. I inserted the child post form into the parent post, and when clicked, it goes to the page identified as containing the child post form. When filled and submitted, the child post is successfully created.
--- https://toolset.com/forums/topic/redirecting-tot-parent-post-after-submission-of-a-child-cred-form/ - I've added this to my function.php, and also tried it using the Snippets plugin, but the child form page just refreshes. You can try it yourself to replicate the problem. Here's the code I used....
//added the child form id '46'
add_filter('cred_success_redirect_46', 'redirect_to_parent', 10, 3);
function redirect_to_parent($url, $post_id, $thisform) {
//added the parent post type slug 'event' to 'wpcf_belongs_slug_id'
$parent_id = get_post_meta( $post_id, '_wpcf_belongs_event_id', true);
return get_permalink( $parent_id );
}
What is the link to your site?
hidden link - this is just a test site.
--- click on any item, this takes you to the single event. There'll you'll find the 'Create new' link which takes you to the form. The URL is, e.g. /add-event-details/?parent_event_id=39. After successful submission, the page just refreshes and the URL is now /add-event-details/?cred_referrer_form_id=46. I want to redirect to the original parent post, where the 'Create new' link resides.
I have also set 'After visitors submit this form: > Go to a page... > Add Event' in the child form settings, as per the advice at https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
Thanks.