Noptin comes with three email templates. To change your email template:-

First, click on Noptin > Settings to open the Noptin settings page.

Next, click on the Emails tab to open the email settings.

open email settings

Finally, set your preferred template in the “Email Templates” drop down…

Select noptin template

… then click on the “Save Changes” button to save your settings.

Save noptin settings

Editing the Email Templates Editing the Email Templates

If you need to make any further changes to the templates, you can take advantage of Noptin’s advanced templating system.

To do this:-

First, create a new folder in your theme’s root folder with the name “noptin” as shown below.

Overide Noptin Templates

Next, copy the “email-templates” folder from “plugins/newsletter-optin-box/templates” into this folder.

Overide Noptin Email Templates

You can then edit the templates as you see fit.

NOTE: This will override all the files in the entire folder. As a result, any changes we make to the original files will not reflect on your site. It is therefore recommended that you keep your templates in sync whenever you update Noptin.

To prevent conflicts with future versions of Noptin, we recommend that you only copy the specific files that you would like to edit. If you do this, remember to maintain the directory structure.

Top ↑

Using your own Email Templates Using your own Email Templates

Before an email template is loaded, Noptin filters the email data through the noptin_mailer_email_data filter as shown below.

Filtering email data before it is sent

You will notice a couple of things that can be really powerful if well utilized.

First, the email data is passed into the filter. This contains a lot of data about the email being built such as ‘campaign_id’ for those emails that were generated from an email campaign.

Second, if the callbacks attached to the above hook do not return a template key in the returned array, the default template that you set above will be used instead.

Third, if the string ‘empty‘ is returned as the template, no template will be used. Instead, the ‘email_body‘ key will be returned.

NOTE: The ‘email_body‘ key is always available on the $data array passed to the filter. This is usually the content of the email as written in the email editor. This filter allows you to pre-process the content before it is rendered inside a template.

What this means is that you can do your own processing on the email then return “empty’ as the template.

It also means that you can pass in the path to a different template and it will be used to load the content.

NOTE: The template can be a path to a single file or a path to a directory/folder containing several template files.

Top ↑

Important Points to Note Important Points to Note

Provide a way for your subscribers to unsubscribe Provide a way for your subscribers to unsubscribe

You should always include a way for your subscribers to unsubscribe. This can be achieved by using [[unsubscribe_url]] as the anchor to an unsubscribe link.

Better still, display the footer text that the administrator has set in the admin dashboard as it usually includes a unsubscription link.

For folder-based templates, you can display the footer text by echoing the value of the $footer_text variable which is available in your template files.

For file based templates, this text is available as $data['footer_text'].

Top ↑

Include a Preview Text Include a Preview Text

Email clients display this text on the email overview screens next to the email subject. Since the Noptin email editor provides a way for administrators to specify a preview text for each email they write, it only makes sense that you display the text in your templates.

For folder-based templates, you can display the preview text by echoing the value of the $preview_text variable which will is available in your template files.

For file based templates, this text is available as $data['preview_text'].

Do not forget to hide the preview text. Failing to do so will result it to being shown when a user is viewing the main email content.

Top ↑

Include a tracking pixel Include a tracking pixel

Noptin uses tracking pixels to know when an email has been opened.

Including one in your template is. All you have to do is is echo the value of the $tracker variable (or $data[‘tracker’]) for those using single file templates.

You do not have to worry about tracking clicks. Noptin will automatically attach that code for you when in post processes the email.

Top ↑

Conclusion Conclusion

Custom templates make Noptin very powerful. Do take a look at the default template for ideas on how your custom templates should look like.

Have questions?   How can we Help?
Updated on

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Natalie

    First of all, I’d like to say, Noptin is best plugin ever!
    but I can’t find guide about how to attach ‘unsubscribe’ link on template.
    Please guide me. Thanks!

  2. Skip to note 2 content
    Contributed by Kevin Lambert

    Hi, Thanks for your great Plugin.

    I was wondering if it is possible to use the HTML E-mail Template from the Plugin WP HTML Mail. So that every email that gets sent from my System looks the same and I don’t have to do the same template twice.

    Thanks and all the best,

    Kevin Lambert