• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Send admin mail only if some fields have input?

Send admin mail only if some fields have input? 6 years 10 months ago #38273

Hi. I've setup a questionnaire to get some feedback from users.

This form is setup with a lot of conditinals so that the first yes/no questions setup with radio field is basically controlling which fields to show on page 2, 3 etc..

There are basically two scenarios:
- the user is happy about everything and hence the textarea fields will not show - we do not want admin e-mails in this case
- the user is unhappy about one or more areas and we show textarea fields according to where the user is unhappy. Here we want the admin email to fire so that we can get the feedback directly.

Anyone done this?
The administrator has disabled public write access.

Send admin mail only if some fields have input? 6 years 10 months ago #38275

This I managed to solve easily.

First, in the admin email set the "to" field to empty. So the default is that the mail does not send.

In the PHP Email Scripts section, add this code to the "Script called before the Admin Email is sent" field:

if($_POST['form']['FIELDTOCHECK1'] || $_POST['form']['FIELDTOCHECK2'] || $_POST['form']['FIELDTOCHECK3'] != '')
$adminEmail['to'] = 'adminemail@toset.com';

You can add as many fields as you want within the () brackets. I've spearated them with || meaning OR. To standard PHP logical operators apply here.

At the end i just check to see if it's not empty. Then I set a to adress for the admin mail if it's not empty in the fields I would like to check.
Last Edit: 6 years 10 months ago by kenneth.c.koppervik.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!