Hi, I have created a post type form to capture submissions but I would like to redirect a user to a page based on the selected option chosen in the select field when they click on submit.
Please could you advise if this is possible or how I can do this?
hidden link
Hello you can use the cred_success_redirect API to redirect based on a User's selection. The general format is like this:
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==12345){
if( $_POST['select-field-slug'] == '1') {
return '<em><u>hidden link</u></em>';
}
if( $_POST['select-field-slug'] == '2') {
return '<em><u>hidden link</u></em>';
}
}
return $url;
}
You would replace 12345 with the numeric ID of this form. You would replace select-field-slug based on the contents of your Form. If the select field is a generic field, you would use the slug of the generic field. If the select field is a Types custom field, you would use the wpcf- prefix and the field slug. You would create one "if" block for each possible option. If you need more direct guidance please take a screenshot showing all the different options for this field, as well as their respective values.