The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If e-mail field is empty, use this address

I would like to pinpoint first name and last name to form fields and use same e-mail ( for all. This is because the e-mail field can be empty.

So how can I edit the code so that if the e-mail field is empty, this address ( is used?

Huh...! So you want all emails to be sent to the same email address, regardless of the name supplied? Interesting use-case.

But you can't really do that without editing the code, unfortunately - and even that may take some work. One solution (simpler, but complete hack) would be to add a hidden field to your form like:

<input type="hidden" name="placeholder_email" value="" />

Then use that as the recipient email. It's ugly, since it would store that dud field value in every submission, but it would work fine and let you get the job done.

- Ben

btw, AWESOME forum name. I was 100% sure you were a spammer, so your post was a nice surprise.
Thank you for the answer! My question was a bit indefinite, sorry. I want the email to be sent FROM the same address, IFuser leaves the email field empty in the form.

It's a job application form, and every applicant doesn't an have e-mail address. So if the forms e-mail field is empty, the sender name and address gets messed up in the email message. It shows two senders:,

So I would need to tell the Form Tools this: if the applicant doesn't have an email address, use this address instead as FROM address: (for example).
Ah, I see!

Are you using the Swift Mailer module, btw, or the default mail functionality? Just wondering, because you shouldn't see two senders: it *should* just default to "none" in the absence of a valid email address, so I'll log this as a bug.

But in the meantime, you could do this with the Submission Pre-Parser module.

1. Just install that module, then create a new rule called "Default email address".
2. For the "When Executed" option, select either the API or "On form submission" checkboxes, depending on your form type.
3. For the PHP code section, add the following code:

PHP Code:
if (empty($_POST["email"]))
$_POST["email"] = "";

You'll need to tweak the $_POST["email"] to whatever field name your email field has.

And that should be it!

- Ben
OK, thanks! It worked. Only problem is that in this case, where user has no e-mail address, the user e-mail information is not valid in the database. Maybe I change the e-mail something like etc... This should solve it.

I use the default e-mail functionality.

-M8R-f08t5x Wink
Good post I like it
You are doing good work

Forum Jump:

Users browsing this thread: 1 Guest(s)