I saw this forum post and I think it is similar to what I’m trying to do, but not really.
The idea is that we have a form that works as a generic lead form, but one of the inputs has something like “I’ve spoken with a representative previously”. If that checkbox is checked, then it should redirect and auto fill the same fields from the first form into the next one. If that isn’t checked, it should go through the usual “FormItSaveForm,email,redirect” hook flow.
I was thinking it might be possible to just have a redirectIf custom hook that checks if a value is present.
If you just call the redirect hook, then it won’t work, as in this case the redirect is only done after all hooks ran successfully.
For example if you have a FormIt tag like this:
[[!FormIt?
&hooks=`redirect,myCustomHook`
...
]]
myCustomHook will still run, although it’s positioned after the redirect hook.
It sounds like you’re on the right track with your approach. You’re correct that if the redirectIf hook executes a redirect, the subsequent hooks won’t run. However, you can manage the flow by checking the input value first and then deciding whether to redirect or continue with the other hooks.
One way to do this is to create a custom hook that handles the logic for checking the checkbox. If it’s checked, you could perform the redirect with the necessary parameters. If not, just allow the process to continue with the usual hooks.