I have a form that i would like when it's sumitted to go to a specific url
At the moment it redirect to lien caché
But i need to redirect to lien caché
Which is the same page into wordpress but a different section.
Is there a way or add a function to acheive this?
Hi, you can choose a different Page in the Form settings screen, or you can use the Forms API cred_success_redirect to set a different redirect URL with some conditions. For example, let's say there is a custom field in the Form called "page-count" that contains a number. If the page count from the Form is higher than 50, you want to redirect to a different URL. If it's less than 50, you want to redirect to the Page in the Form settings. You would set up that custom code like this:
add_filter('cred_success_redirect', 'custom_redirect_to_custom_url',10,3);
function custom_redirect_to_custom_url($url, $post_id, $form_data)
{
$forms = array( 12345 );
if ( in_array( $form_data['id'], $forms ) ) {
$page_count = get_post_meta( $post_id, 'wpcf-page-count', true );
if( intval( $page_count ) > 50 ) {
$url = "<em><u>lien caché</u></em>";
}
}
return $url;
}
More information about this API is available here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect