Form Redirect Plug In Condition

Status
Not open for further replies.

griffin

Member
I have a form which I wish to redirect upon submission to a particular page. I want the submission message for a user who entered an email address to be different from a user who didn't enter an email address.

Basically the submission message says "you have been sent an email..." for the user who entered an email address - or - "we will be in contact... " for the user who doesn't enter an email address.

I would really appreciate some assistance with this. I have tried creating two redirect plugins in the form - one for each situation with conditions:

return (int) '{register___email}' === 0;

and

return (int) '{register___email}' === 1;

and I am not getting the result I want i.e. different submission message if has email address to doesn't have email address.

Should I have two redirects and what am I doing wrong with condition? Cheers
 
What is your "On" value (New, edit, both)?
For debugging you can add
$s = '{register___email}';
var_dump($s);exit;
in your condition(s) (one by one).
 
Is set on New. Debugging returned email address when had one and " " when didn't? Not sure where that leads me. Strange but when I unpublished the first redirect plugin (no email address) and entered an email address I got the "no email address" submission message.

Any other advice on this?
 
So register___email is a field element with the actual email in it? Not sure why you'd cast that to an int, and I'm pretty sure it'll always return 0. An email address isn't an integer. :)

Try ...

PHP:
return empty('{register___email}');

.... and !empty().

Or, if you want to account for an otherwise empty field with just some spaces in it ...

PHP:
return trim('{register___email}') === '';

... and !==.

-- hugh
 
Thanks very much for your assistance with this - got it to work with a bit of tinkering and interpreting.

I'm not sure why I had it as (int) either - I got this from the examples provided in the wiki and forum. It isn't always easy to follow and interpret the solutions provided in the wiki and forums for a novice like myself, so your patience is very much appreciated. At times it's like solving a cryptic crossword.

Cheers!
 
I understand.

Basically, you only do that "(int)" thing if the value you are expecting is an integer.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top