Adding a MailerPress Form with Your Page Builder to Collect Emails

A shortcode is a short code in square brackets that WordPress replaces with content. The [mailerpress_optin] shortcode displays a MailerPress sign-up form anywhere on your site: in a page builder module or widget (Elementor, Bricks, Divi and others), in the classic editor, or in your theme’s PHP templates. It is included in MailerPress (free).

Using the block editor? The Subscription Form block is easier to set up. With MailerPress Pro, Elementor, Bricks Builder and Divi also have dedicated integrations: Elementor, Bricks Builder and Divi Builder.

Quick setup

Add this shortcode where the form should appear:

[mailerpress_optin list="1"]

Replace 1 with your list ID. On the MailerPress lists page, the Shortcode column shows a ready-to-copy shortcode for each list. The tags page does the same for tags. Without list, new contacts go to your default list (see Manage Your Contact List).

By default, the form shows only the email field and a Subscribe button. Add attributes (options written inside the brackets, like list="1") to change it.

Shortcode attributes

AttributeDescriptionDefault
listList IDs, separated by commas, for example list="1,2".Default list
tagsTag IDs, separated by commas, for example tags="5,10".None
show_first_nameShow the first name field.false
show_last_nameShow the last name field.false
email_requiredMake the email field required.true
first_name_requiredMake the first name field required.false
last_name_requiredMake the last name field required.false
email_labelLabel of the email field.Email
first_name_labelLabel of the first name field.First Name
last_name_labelLabel of the last name field.Last Name
email_placeholderPlaceholder of the email field.Enter your email
first_name_placeholderPlaceholder of the first name field.Enter your first name
last_name_placeholderPlaceholder of the last name field.Enter your last name
button_textText of the button.Subscribe
button_colorButton background color (hex code, for example #0073aa).#000
text_colorButton text color (hex code).#fff
border_radiusButton border radius, for example 8px.0px
success_messageMessage shown after a successful sign-up.Thank you for your registration.
error_messageMessage shown when the sign-up fails.Oops! Something went wrong. Please try again.
redirectPage to open after a successful sign-up: the ID of a post, page or other post type, or a full URL.None

The default labels and messages appear in your site’s language.

Examples

Simple form with a custom button:

[mailerpress_optin list="1" button_text="Register"]

Form with tags:

[mailerpress_optin list="1" tags="5,10" button_text="Join us"]

Styled button:

[mailerpress_optin list="1" button_color="#e74c3c" text_color="#fff" border_radius="8px"]

Redirect to a thank-you page (ID 123) after sign-up:

[mailerpress_optin list="1" redirect="123"]

Complete form with a required first name:

[mailerpress_optin list="1" tags="5" show_first_name="true" first_name_required="true" show_last_name="true" first_name_label="First Name" last_name_label="Last Name" email_label="Email" email_placeholder="[email protected]" button_text="Subscribe" button_color="#2c3e50" success_message="Thank you for subscribing!"]

Use the shortcode in a PHP template

To display the form from your theme or child theme, add this line to a template file:

<?php echo do_shortcode( '[mailerpress_optin list="1"]' ); ?>

Good to know

  • Double opt-in (the new contact confirms by clicking a link in an email) follows MailerPress > Settings > Sign-up Confirmation, enabled by default and recommended. No shortcode attribute changes it. See Enable sign-up confirmation (double opt-in).
  • Colors must be hex codes (for example #000, #fff or #0073aa). An invalid color falls back to the default.
  • For true/false attributes, use "true" or "false". The values 1, yes and on also mean true.
  • Your theme styles apply to the form. To target it in custom CSS, use the mailerpress_shortcode-optin-form class. The button also has the standard button class.
  • Rate limiting (a cap on sign-ups in a short time), set in MailerPress > Settings > Spam Protection, applies to shortcode forms. See Security & Spam Protection.