Newsletters: Hardcoded Subscribe Form
The subscription form hardcoding feature allows you to insert a mailing list subscription form into your WordPress theme (or any other part of your WordPress website) by using PHP code directly inside of your template files.
In order to hardcode a subscription form, open any of your theme .php files inside the theme folder which is located inside “/wp-content/themes/“. Below are some examples.
Step 1: Initialize a wpMail Object
Always insert this line first to initialize the wpMail class before executing the hardcoded function. This is the first line of code you’ll need.
$wpMail = new wpMail();
Step 2: The “hardcoded” function
This is the second line of code you’ll need. The hardcoded function outputs the form but you need to tell it what type of form to display. See the options below.
Specific Mailing List
Insert a subscription form for a specific mailing list using the ID of the mailing list as the first parameter for the hardcoded function.
$wpMail -> hardcoded(3);
Select Drop Down
Insert a subscription form with a select drop down menu showing all your available, non-private mailing lists in the database.
$wpMail -> hardcoded('select');
Multiple Mailing Lists
Allow subscribers to choose multiple mailing lists they wish to subscribe to using a list of checkboxes with all your available, non-private mailing lists in the database.
$wpMail -> hardcoded('checkboxes');
Auto by Language
Before you can use this feature, you’ll need to download, install and activate the Language Switcher WordPress Plugin by Poplar ProductivityWare. Once you have activated it, the Newsletters plugin will automatically detect it and add functionality to your hardcoded newsletter subscription forms. Use the PHP code below to hardcode a subscription form into your WordPress theme which will automatically pick the right mailing list as specified in your “Configuration” section of the Newsletters plugin.
$wpMail -> hardcoded('language');