Using variables in your form or messages

A relatively unknown feature of the plugin is the fact that you can use certain variables inside your form, your form success and error message or even the checkbox label text for some dynamic content.

The variable will be replaced with a certain value, like the current number of total subscribers on the selected list or the email of the person who just filled out your sign-up form.

How to use dynamic variables

Just include the variable in your form and the plugin will automatically replace it with the corresponding value. If the value is not known, the plugin will replace it with an empty string.

Example 1: successfully subscribed message with email
It can help to show the email address visitors used for a pointer as to in which email inbox they can find the confirmation email. To do that, use {email} inside your success message.

Thank you! Please check your {email} for a confirmation email.

Example 2: form with number of subscribers

<p>
	Join {subscriber_count} others, stay updated by subscribing to our newsletter.
</p>
.... (rest of sign-up form)

Example 3: data from URL
Sometimes you want to prefill your form fields with data from the URL (or other data present in the current request).

You can use the `{data key="NAME"}` shortcode for that, where the key attribute tells the plugin which request variable to use.

Here's an example grabbing fname en email from the URL.

URL: https://..../?email=danny@email.com&fname=Danny

<p>
	<input type="text" name="FNAME" value="{data key="FNAME"}" />
</p>	
<p>
	<input type="email" name="EMAIL" value="{data key="EMAIL"}" />
</p>

Was this article helpful? ·