Hive Mail adds four shortcodes and one block. The signup form has a shortcode and a block. The other three shortcodes draw the Unsubscribe, Email preferences and Subscription confirmed pages inside your theme.
The signup form shortcode #
[hivemail_form id="3"]
| Attribute | Required | Meaning |
|---|---|---|
id |
Yes | The number of the signup form. It is shown in the shortcode on Audience > Forms and in the form's Put it on a page card |
id is the only attribute. Any other attribute is ignored. The form's own look and wording are set in the form editor, not in the shortcode (see Signup forms: create and edit).
To get the ready-made shortcode: open the form in Audience > Forms, find the card Put it on a page, click Copy next to Shortcode. Paste it into a Shortcode block, or into the shortcode element of a page builder.
What visitors see depends on the form:
- A form that is on and has a list is drawn as plain HTML that also works without JavaScript.
- A form that is off, has no list, or no longer exists shows nothing to visitors. People who manage Hive Mail see a one-line note instead: "This signup form is turned off, so visitors do not see it.", "This signup form has no list to add people to. Choose one in Hive Mail → Forms." or "This signup form no longer exists." (also shown when
idis missing). - The same form can appear more than once on a page and on many pages.
- The form's stylesheet and script load only on a page that carries a form. The form sets no cookie.
Tip: A cached page is fine. The form's time token is signed per form and does not depend on the visitor. A page cached for more than a day asks the visitor to reload.
The signup form block #
| Item | Value |
|---|---|
| Block name | hivemail/form |
| Title in the inserter | Hive Mail signup form |
| Category | Widgets (keywords: newsletter, subscribe, signup, email) |
| Attribute | formId (integer, default 0) |
| Alignment | Wide and full |
| Rendering | On the server, so the page shows what the editor shows |
To add it:
- In the block editor click + and search for
Hive Mail signup form. - In the block's placeholder, open the drop-down Signup form and choose the form. A form that is off carries "(off)".
- Update the page.
The block's side panel has the same Signup form drop-down. In the editor the block shows a picture of the form; nothing can be sent from there. A block with no form chosen draws nothing on the page.
Saved block markup looks like this. You can put it in a block template or a pattern:
Place a form from PHP #
<?php
// In a template file:
echo do_shortcode( '[hivemail_form id="3"]' );
// Or with the id in a variable:
$form_id = 3;
echo do_shortcode( sprintf( '[hivemail_form id="%d"]', $form_id ) );
The output is already filtered for safe HTML. You do not need to escape it again.
The three public page shortcodes #
Hive Mail makes three published WordPress pages when it is activated: Unsubscribe, Email preferences and Subscription confirmed. Each holds one of these shortcodes:
| Shortcode | Shows | Attributes |
|---|---|---|
[hivemail_unsubscribe] |
The unsubscribe card (reason list, the Unsubscribe button, then the "unsubscribed" message) | none |
[hivemail_preferences] |
The preferences card: name, the public lists, Save preferences | none |
[hivemail_confirmation] |
The double opt-in card with the Confirm my subscription button | none |
They take no attributes. They show something useful only when the page is opened from an email link, because the link carries one person's signed key in ?t=. A page opened without a valid key shows "This link does not work" (with HTTP status 400). Opening the page never changes anything; the person has to press the button.
Hive Mail answers a page that holds one of these shortcodes before the theme draws it. It sends no-cache headers, marks the page noindex and defines DONOTCACHEPAGE, so most cache plugins skip it. If yours does not, exclude the three pages by address.
To use a page of your own, go to Settings > Compliance > Your own pages > Use a different page, choose the page, put the shortcode on it and save. See Unsubscribe and email preference pages and Settings: Compliance.
Warning: Do not delete the shortcode from one of the three public pages: the page would show nothing. Settings > Compliance > Your own pages marks such a page No shortcode and offers Reset to default content. In templates call
do_shortcode(), not plugin classes, which can change.
Next: Put a signup form on a page, Spam protection and CAPTCHA.