The code above is the basic way to do a redirect based on the custom field value. What you need to do is to replace the 'wpcf-custom-field' with the slug of your custom field keeping the wpcf- prefix.
This support ticket is created 5 years, 7 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.
Tell us what you are trying to do?
When the user clicks submit, they go to specific page BASED on how they answer a question. The option "Go to a Specific Page" already exists, I just need to make that specific to be determined by how the user answers the question.
Is there any documentation that you are following?
Not able to find anything specific to this.
Is there a similar example that we can see?
Not with Toolset.
The code above is the basic way to do a redirect based on the custom field value. What you need to do is to replace the 'wpcf-custom-field' with the slug of your custom field keeping the wpcf- prefix.
Please try this and let me know if it helps.
Thanks,
Shane
One question though, Since it's going in the custom code section of the Settings area, I'm thinking it won't be exported if I make a module. Is this correct?
So here's the code I added as a snippet to the toolset custom code in settings, and below that is the form. When it didn't work the first time I changed the id from 12 to 1056 as that's the number of the form.
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==1056 && isset($_POST['solve_issue_director'])){
if($_POST['solve_issue_director'] == 'problemsolved'){
return 'hidden link';
}
if($_POST['solve_issue_director'] == 'problempersists'){
return 'hidden link';
}
}
return $url;
}
?>
--------------------------
FORM Code
[credform]
[cred_field field='form_messages' class='alert alert-warning']
<div class="form-group">
<label>Troubleshooting Support Checklist Title</label>
[cred_field field='post_title' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Troubleshooting Support Checklist Content</label>
[cred_field field='post_content' output='bootstrap']
</div>
<div class="form-group">
<label>Have you tried turning it off and on again?</label>
[cred_field field='off-on-example' force_type='field' class='form-control' output='bootstrap']
</div>
Please note that for the redirection hooks to work, the form must be set to redirect to a specific page or a post after the submission. If for example, the form options are set to “Keep displaying this form” or “Display a message instead of the form” after submission, the redirection hooks will not work.