This support ticket is created 7 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am trying to use a CRED hook to reload the current page after a form is submitted.
Use the code below (found here in the support forum) on several forms and it works unless the post status is "draft".
Can you please help me alter the code so that it works on forms that creates posts with status "draft".
(don't know php...)
/* reload current page after new post */
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ( in_array($form_data['id'], array(3856, 3684, 5190, 5202, 5080) ) ) //Form IDs
return (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
return $url;
}
The form creates a child post with status published.
It is placed on the parent post page.
The parent has status draft.
The custom redirect works if parent post is published but not if it is a draft.
Wonder why 🙂
Well - only users with admin rights can see the draft posts and its not logical to redirect the user to draft post at all. Visitors should able to see the published posts. I would suggest you correct the settings.
Also - its not correct that you set the draft post as the parent. The post type relationship should be maintained by following the normal process that means parent post should be published.