Skip Navigation

[Resolved] Redirect to a page based on select field

This support ticket is created 4 years, 8 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1556173
Step 8.png

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

#1556581

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.