Postalion

PostalionDocumentation13

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.

3 min read

Shortcodes

[postalion_form title="" description="" button_text="" show_name="true"
    placeholder_email="" placeholder_name="" success_message="" redirect_url=""
    list="" tags="" fields="" class="" id=""]
[postalion_subscriber_count list="" format="number" text="subscribers" before="" after=""]
[postalion_unsubscribe title="" description="" button_text="" placeholder="" success_message=""]
[postalion_archive limit="12" lists="" empty="" class=""]

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( 'reader@example.com', array(
    'first_name' => 'Ana',
    'last_name'  => 'Pop',
    'source'     => 'my-form',
    'lists'      => array( 'newsletter', 'workshops' ), // slugs or IDs; empty = default list
    'tags'       => array( 'customer' ),                // names or slugs; a new name is created
    'fields'     => array( 'company' => 'Acme' ),       // custom field key => value
) );

For someone already subscribed, Postalion_Tag_Manager::add_subscriber( $id, array( 'customer' ) ), Postalion_Tag_Manager::remove_subscriber( $id, array( 'customer' ) ), Postalion_Tag_Manager::has_tag( $id, 'customer' ) and Postalion_Field_Manager::set_values( $id, array( 'company' => 'Acme' ) ) / get_values( $id ) do what they say; Postalion_Tag_Manager::ensure( 'customer' ) returns a tag's ID, creating it if needed.

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_digest_include_post( $include, $post ): return false to keep a post out of the digest.
  • postalion_digest_content( $html, $posts, $total ): the HTML of a digest.
  • 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_subscriber_tagged( $subscriber_id, $tag_id ) and postalion_subscriber_untagged( $subscriber_id, $tag_id ): a tag was put on or taken off a subscriber.
  • 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_tags, postalion_subscriber_tags, postalion_fields, postalion_subscriber_meta (custom field values), 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.

Your list. Your server. Your letters.

Install it, send yourself a test, and see whether it suits you.

Download Postalion, free