5

I know that there is a param for safecracker/safecracker registration form called return. You could define a static url.

Is there a way for a safecracker/safecracker registration form to redirect to a url based on some option inside the form itself?

I am not just talking about setting the url directly like(if even this is possible)

{exp:safecracker return="[redirect_url]"}
  ...
  <input type="hidden" name="redirect_url" value="redirect/to/something">
  ...

I am talking about more advanced stuff like(using pseudocode)

if dropdown value = 1 then redirect to X
else if dropdown value = 2 then redirect to Y
else redirect to Z 
3

This functionality isn't built in, but you could utilize the ENTRY_ID constant inside the return="templategroup/template/ENTRY_ID" parameter to point to an intermediate template to do a dynamic redirect.

Then, within that template, you can use a Channel Entries tag like to load the new entry, where you could have a conditional to do redirects. Something like this:

{exp:channel:entries dynamic="no" entry="{segment_3}"}
    {if some_field_in_safecracker_form == "some value"}
        {redirect="somewhere/over/the/rainbow"}
    {if:else}
        {redirect="somewhere/else"}
    {/if}
{/exp:channel:entries}
1

You could try to use JS to override the form's hidden input fields. There should be one named "return", so try to use JS to override what is already there. Obviously update the field use the change() event.

I am not 100% sure this will work, but it's what I would try first. If not I will have to add it to the list of features to add in the next update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.