Postalion

Documentation

For developers

Postalion is plain WordPress: custom tables, wp_mail(), WP-Cron, shortcodes, one block, and a handful of hooks. Nothing here needs a build step.

Shortcodes

[postalion_form title="" description="" button_text="" show_name="true"
    placeholder_email="" placeholder_name="" success_message="" redirect_url=""
    list="" class="" id=""]
[postalion_subscriber_count list="" format="number" text="subscribers" before="" after=""]
[postalion_unsubscribe title="" description="" button_text="" placeholder="" success_message=""]

The block postalion/form renders through the same code as [postalion_form], so styling one styles both. Styles come from public/css/forms.css; override them in your theme.

Subscribing from code

$result = postalion_subscribe( '[email protected]', array(
    'first_name' => 'Ana',
    'last_name'  => 'Pop',
    'source'     => 'my-form',
    'lists'      => array( 'newsletter', 'workshops' ), // slugs or IDs; empty = default list
) );

It behaves like the form: double opt-in applies when it is on, users of the site are handled as users, and the result is a subscriber ID or a WP_Error with a readable message. Use it from any form plugin's submission hook.

Filters

  • postalion_email_content( $html, $email, $newsletter_id ): the HTML of each outgoing email, after personalisation. $newsletter_id is 0 for test emails.
  • postalion_newsletter_recipients( $recipients, $newsletter ): the addresses a newsletter goes to, before it is queued.
  • postalion_templates( $templates ): add or remove email templates. A template is a folder with a template.html that uses the placeholders.
  • postalion_logo_url( $url ): the logo in the email header (the theme's custom logo by default; return an empty string to show the site name).
  • postalion_notify_post( $notify, $post ): return false to keep a post out of the new-post notification.
  • postalion_post_newsletter_content( $html, $post ): the HTML built from a post for the notification.
  • postalion_show_popup( $show ): whether the popup may appear on the current page.

Actions

  • postalion_subscriber_subscribed( $subscriber_id, $email ): a new subscriber was added (with double opt-in off) or confirmed.
  • postalion_subscriber_confirmed( $subscriber_id, $email ): a subscriber clicked the confirmation link.
  • postalion_email_sent( $email, $newsletter_id, $sent ): an email was handed to wp_mail(); $sent says whether it was accepted.
  • postalion_admin_menu: add screens to the Postalion menu.

Constants

  • POSTALION_SMTP_PASSWORD: the SMTP password, kept out of the database.

Tables

All prefixed with your table prefix: postalion_subscribers, postalion_lists, postalion_list_subscribers, postalion_newsletters, postalion_email_queue, postalion_links, postalion_email_log, postalion_logs and postalion_wp_user_exceptions (users who opted out). Read them if you need to; write through the plugin's classes.

Back to the documentation.