Trigger an URL

By: Lasse Kornerup | Asked: 09/20/2022
ForumsCategory: Code HelpTrigger an URL
Lasse Kornerup asked 2 years ago

Hi all, I have build a quiz with multiple answers that gives a value.

The total score (ID 13) should redirect the quiz-taker to an URL - depending the score.

I have 3 different URLs after score:

0-10

11-31

31+

For some reason the total 0-10 dont work and redirects to the URL for 11-30?

My code:

https://[if 13 greater_than="1"less_than="10"]alfarehab.dk/ludomani[/if 13] [if 13 greater_than="11"less_than="30"]alfarehab.dk/stofmisbrug[/if 13] [if 13 greater_than="31"]alfarehab.dk/hjaelp-til-paaroerende/[/if 13]

Anyone see the problem?

Regards Lasse

Walter JonesWalter Jones replied 2 years ago

Does the 31+ work?

Lasse Kornerup replied 2 years ago

Yes - so odd the first dont?

4 Answers
Rob LeVineRob LeVine answered 2 years ago
I see a typo with greater_than="1"less_than="10 and there's no space between the "1" and the "less_than"
Lasse Kornerup replied 2 years ago

Seen that to, and tried to make space, but no effect. I have writtin it the same way with the other 2 that works?

Rob LeVineRob LeVine replied 2 years ago

One other thing is a logic flaw. "greater_than" 1 and "less_than" 10 means you're only covering 2 through 9. Maybe that's the problem? Similar issues happen with the other ranges.

Lasse Kornerup answered 2 years ago

Hi guys, Im getting quite frustrated :-)
Now nothing works?
This is my code for triggering URL:
https://[if 13 greater_than="0" less_than="11"]alfarehab.dk/ludomani[/if 13] [if 13 greater_than="11" less_than="30"]alfarehab.dk/stofmisbrug[/if 13] [if 13 greater_than="31"]alfarehab.dk/hjaelp-til-paaroerende/[/if 13]

HEEEELP! :-D

Walter JonesWalter Jones replied 2 years ago

Other than changing the numbers what else has changed? Are you using this in a redirect on form submit I presume?

Have you reached out to FF official support yet?

Lasse Kornerup replied 2 years ago

Hi Walter.
Nothing else has changed. Thougt it were a cache issue but so lucky am i not 🙁

And yes, its a redirect after submitting answers in a form/quiz. The total score should simply redirect to an URL. If i paste only one URL with no scores all is good.
I think it is something with the code - but i cant see what?

No FF is not contacted yet - would see if it just were someting simple ive done wrong first. But i might have to reach out.

Rob LeVineRob LeVine replied 2 years ago

There's still a logic error in that scores of 0, 11, 30 and 31 are not covered. Other than that, I can't see helping further without at least a link to the page that's having the issue.

Lasse Kornerup replied 2 years ago

Hi Rob,
I have tried to change 0 to 1. Changed the quiz so the lowest score are 1 and no effect.
The quiz are not live, and i have tested in a preview on blank page.

But now its live on a testpage:

https://www.alfarehab.dk/aaamisbrugsivirksomheder/

Rob LeVineRob LeVine replied 2 years ago

How should I answer the questions such that the issue happens?

Lasse Kornerup replied 2 years ago

Hi Rob,
You can answer with the first questions (they score 0)

Victor Font answered 2 years ago
I would write the conditionals this way: [if 13 less_than_or_equal_to="10"]alfarehab.dk/ludomani/[/if 13] [if 13 greater_than="10" less_than="31"]alfarehab.dk/stofmisbrug/[/if 13] [if 13 greater_than_or_equal_to="31"]alfarehab.dk/hjaelp-til-paaroerende/[/if 13] Don't forget to prepend the protocol to the URLs.
Lasse Kornerup replied 2 years ago

Hi Victor,
Super - ill try that! 🙂

Lasse Kornerup replied 2 years ago

Now i get this URL: https://www.alfarehab.dk/wp-admin/admin-ajax.php?action=frm_forms_preview&form=alkoholtest2&frm_page=10

My code:

[if 13 less_than_or_equal_to="10"]https://alfarehab.dk/ludomani/[/if 13] [if 13 greater_than="10" less_than="31"]https://alfarehab.dk/stofmisbrug/[/if 13] [if 13 greater_than_or_equal_to="31"]https://alfarehab.dk/hjaelp-til-paaroerende/[/if 13]

Victor Font replied 2 years ago

So wait, let me see if I understand this correctly. This is a long thread and I had to look it over a couple of times.

You are entering this conditional on the form's General Settings page in the On Submit section after you've changed the drop down from "Show Message" to "Redirect to URL", correct?

If you didn't make a mistake entering the code, then there's either something wrong with your system or you've uncovered a bug somewhere. It could be Formidable or it could be another plugin causing interference. Whatever the case, it's beyond the help you can receive from a community forum manned primarily by volunteers, such as me. You have to troubleshoot the issues or open a support ticket with Strategy 11.

The logic I gave you is correct. I don't know what the value you were assessing is, so I can't confirm if the URL is correct, but I can confirm that the appending of /wp-admin/ does not appear correct. I problem like that can be anywhere. Things that pop to my mind are permalinks, caching, server caching, security plugins, plugin conflicts, and out of date server software. Any of these can be a root cause and I would check all of them before I opened a ticket to claim a Formidable bug.

Good luck in tracking this down. I'm going to close this issue now since you have a path forward.

Rob LeVineRob LeVine answered 2 years ago
For anyone still following or someone else stumbling on this later, I helped Lasse get the root of the problem (or at least the final part of the problem).  Following the directions here -> https://formidableforms.com/knowledgebase/conditionals/#kb-redirect-to-a-url-conditionally I noticed that there are absolutely no spaces in the code.  The code that was bouncing around here had spaces in between the close and open square brackets (between the end-if and the next if) and that was throwing off the URL that was getting generated.  Removing all spaces solved the issue.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right