Using Dynamic Variables in WatuPRO Email Field

WatuPRO comes with an option to send email with respondent’s answers when a test is submitted. This is found in Edit Quiz page -> User and Email Related Settings tab and is pretty straightforward. You can select to send the email to the user and yourself  -the site administrator, to the email address defined in your WatuPRO Settings page:

In the WatuPRO Edit Quiz page -> User and Email Related Settings you can override this setting and set another email address to the admin’s email for that specific quiz. But this is not all. You can also use several variables to dynamically define the receiver of each quiz attempt depending on the specific quiz taker. You can use variables together with fixed email address or alone. Here’s and example and then we’ll deconstruct all the possible variables:

As you can see, you can mix and place several possible emails together, separated by comma.

Variables from “Ask for user contact details” section

If you scroll down on the same tab of the Edit Quiz page you will see the Ask for user contact details section which allows you to request several contact fields at the beginning or the end of the test. As you can see each of these fields can be asked for or not asked for, or made required/mandatory, and each of them has an associated variable:

So each of these fields can be used as dynamic source of email address. For example in the above image we have asked for partner’s email address in custom field 1. So if we want to send the user’s quiz results to their partner we’ll add the variable %%FIELD-1%% in the list of email addresses to send to.

Group Managers

You can also use the variable %%GROUP-MANAGERS%% to send emails to all users with “manage quizzes” rights that are from the same user groups as the respondent (provided the respondent is a registered user). User groups are defined in WatuPRO User Groups page and you can edit each user’s group in their profile, set groups to be automatically assigned on registration, and so on.

So by using %%GROUP-MANAGERS%% in the field the results of the test taker will be sent to all those users.

 

Dynamic data from user meta fields

Here’s the most powerful part which works for respondents that are registered users. You can construct your own variables based on keys from the wp_usermeta table like this:

{{{usermeta-meta_key}}} where key_name is the name of the key in wp_usermeta. If the meta data with the key of that user contains an email address, the results will be sent to it. If the key contains a number, the program will assume user ID and will send the results to that user’s email.

So let’s deconstruct the variable from our example:

The variable {{{usermeta-company_manager}}} says that we’ll get the data from wp_usermeta where the key is “company_manager” and the user_id field contains the ID of the currently logged user.

This meta data could be either manually entered by you or generated by other plugin or custom code. It is your responsibility to be careful with the meta data and not use anything unsafe that could expose personal data to someone who isn’t supposed to see it.