I would like to make custom redirection after CRED submit:
1) when user create child CPT after submit go back to parent CPT
2) when user create CTP without parent go back to the page where I insert button linked to CRED form
I was trying to use:
https://toolset.com/documentation/user-guides/cred-api/#csr
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==12)
return '<em><u>hidden link</u></em>';
return $url;
}
but I am not able to set 'hidden link'; the way to get results - nothing is working for now
I am afraid this code to block to access to wp-admin can cause the problem?
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
but even in admin mode I cannot reach any results
Hi, Thanks for contacting Toolset support forums.
The "cred_success_redirect" was meant to work when the form setting for "After visitors submit this form" is set to "Go to a page..." [Check screenshot].
So if you have it set to any other options, the steps required to fix this issue is:
1. Go to form settings and change "After visitors submit this form" from "Keep displaying this form" to "Go to a Page".
2. Select a Page to redirect to, add make redirection delay 0.
3. Add your code snippet to functions.php in your active theme.
4. Make sure the snippet contains the correct form ID.
Please let me know if that solves your problem.
Thanks.
Hi Ahmed,
thank you for explanation but on the end I choose other way to do it and it working fine.