Re is out: see what's new Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

Hooks

Updated 6 min read 10 views

All of Re:Maily’s PHP hooks start with remaily_. Filters return a value; actions only run.

Showing a form

HookKindUse
remaily_initactionRe:Maily has started
remaily_render_argsfilterA form’s class and html_id, wherever it shows
remaily_fieldfilterA field’s settings just before it’s printed
remaily_field_controlfilterA field’s control HTML
remaily_form_attributesfilterAttributes of the <form> element
remaily_form_htmlfilterThe form’s inner HTML
remaily_hidden_inputsfilterHidden inputs sent with the form
remaily_token_{name}filterWhat a reserved token prints, such as [[captcha]]
remaily_script_configfilterWhat the front-end script reads for a form
remaily_enqueueactionA form’s assets are loading
remaily_template, remaily_template_varsfilterWhich template file loads, and the variables it gets
remaily_iconfilterThe SVG of an icon
remaily_form_closedfilterClose a form: return a message, such as “Registration has ended”, and it shows instead of the form and answers anyone who sends it. Return ” to keep it open. Use it for dates, an entry limit or a schedule.
remaily_form_renderedactionA form was printed, the editor’s Preview included: count views

Styles

HookKindUse
remaily_stylesfilterThe styles offered and their names
remaily_include_styles, remaily_exclude_stylesfilterNarrow the styles offered, * as a wildcard
remaily_default_stylesfilterfalse stops the plugin’s own CSS

Fields and editor

HookKindUse
remaily_field_typesfilterAdd a field type
remaily_field_defaults, remaily_field_schema, remaily_field_sanitizefilterAdd a setting to field types
remaily_starterfilterWhat a new form starts with
remaily_editor_enqueueactionLoad an editor script
remaily_editor_datafilterThe data the editor reads
remaily_config_defaults, remaily_config_sanitizefilterA form’s own settings, such as an add-on tab’s
remaily_save_formfilterCheck a form before it’s saved; a WP_Error stops the save
remaily_saved_formactionA form was saved
remaily_settings_sections, remaily_settings_tabsfilterFields and tabs in Settings
remaily_cf7_importedactionA Contact Form 7 form was imported
remaily_preview_before, remaily_preview_afteractionAround the form in the editor’s Preview
remaily_preview_classes, remaily_preview_body_classfilterClasses of the editor’s Preview
remaily_field_menufilterMove a field type’s button to the main row or the More menu
remaily_countriesfilterThe countries of the Country field and the Tel masks: code => [ name, dial, mask, trunk ], with # for each digit of the mask
remaily_tel_masksfilterOne Tel field’s masks, the first one tried first: ( $masks, $field ), each code => [ mask, trunk ]
remaily_placesfilterAdd a chip with nothing to set up, like Captcha and Response
remaily_default_sources, remaily_default_valuefilterThe choices under Fill from, and the starting value a field gets from them
remaily_docs_url, remaily_support_urlfilterWhere the Documentation and support links in the admin go
remaily_import_formsactionImport forms from a file, a URL or JSON, such as in a theme’s demo import. The second argument replaces forms with the same shortcode.
remaily_file_typesfilterThe types File fields may take, as extension => kind. Images, audio, video, PDF and txt by default. Add or remove types; each must also be one WordPress allows. Example: fn( $types ) => $types + [ ‘docx’ => ‘Word document’ ]
remaily_field_infofilterWhat [[name:key]] can show of a field: key => [ label, value ]. Add keys of your own; they appear under Use in text in the editor.

Sending a message

HookKindUse
remaily_spam, remaily_skip_spam_checkfilterMark a message as spam, or skip the checks
remaily_spam_checksfilterTurn spam checks off for a form
remaily_skip_captchafilterSkip the captchas for a message, as a paid message does
remaily_akismet_paramsfilterWhat is sent to Akismet
remaily_remote_ipfilterThe visitor’s IP address, behind a proxy Re:Maily doesn’t recognize
remaily_spam_caughtactionA check caught a message
remaily_posted_datafilterThe posted values, after cleaning
remaily_validate_{type}, remaily_validatefilterField errors
remaily_before_send_mailactionBefore the mails go
remaily_paymentfilterThe amount, currency or description a Stripe or PayPal field asks for
remaily_payment_gatewaysfilterAdd a payment provider
remaily_skip_mailfilterSend no mail for this message
remaily_mailfilterA mail’s to, from, subject, body, headers and attachments
remaily_mail_tagfilterWhat a mail tag prints
remaily_special_mail_tagsfilterYour own special tags, so the Mail tab knows them
remaily_mail_sent, remaily_mail_failedactionAfter the mail went, or failed
remaily_entry_data, remaily_entry_savedfilter, actionThe entry before and after it’s saved
remaily_webhook_payloadfilterThe JSON sent to webhooks
remaily_keep_uploadsfilterKeep uploaded files after mailing
remaily_submittedactionThe message is done
remaily_responsefilterThe reply sent back to the browser
remaily_messages, remaily_messagefilterAll messages, or one message’s text
remaily_brevo_contactfilterThe contact sent to Brevo: email, listIds, attributes. An empty array sends nothing.

The entry screen

HookKindUse
remaily_entry_actionsactionButtons beside All entries and Move to trash, such as Reply. Gets the entry ID.
remaily_entry_viewactionMore of the entry under its details, such as notes or a status. Gets the entry ID, its values and the visit.

The entries list is WordPress’s own list of the remaily_entry post type, so its columns, bulk actions and statuses use WordPress’s hooks, such as manage_remaily_entry_posts_columns.

Add-ons

An add-on is a plugin of its own (Requires Plugins: remaily) that talks to Re:Maily through these hooks. Re:Maily has no licenses or paid features of its own: an add-on that needs a license keeps it, checks it and shows it itself.

HookWhat it does
remaily_addonsLists your add-on: name, version, docs, settings (the Settings tab its options are in), premium (only the word on its card), ready (false: don’t start it yet), readonly (a note: its options and form tab can’t be changed), status ([ label, tone ] on its card) and panel (a callable printing its own part of its window, such as a license form). An add-on that isn’t in the catalog also passes description, category, tags, icon and color.
remaily_addon_init_{slug}Runs while your add-on is on and ready: hook the rest here.
remaily_addons_catalogThe cards of the Add-ons page, shown before an add-on is installed too. Change an entry, such as its description.
remaily_addon_noticedo_action( 'remaily_addon_notice', $slug, $type, $text ) after your own form posts: the add-on’s window opens with that note (success, warning or danger).
remaily_settings_sectionsYour options in Settings: a node marked 'addon' => slug.
remaily_form_tabsA tab of your own in the form editor, drawn from a controls tree.
remaily_logosYour logo by name, [ 'my-crm' => MY_PATH . 'assets/my-crm.svg' ], then draw it with remaily_logo( 'my-crm' ).
remaily_formula_functionCalculator add-on: a function of your own in formulas. Gets ( null, $name, $args, $context ), $context['form'] being the form; return a number or text for your name, null for others. Its twin in the browser is window.remailyFormulaFunctions.name = ( args, { number } ) => …. The Coupons add-on adds discount() this way.
add_filter( 'remaily_addons', fn( $addons ) => $addons + [
    'my-crm' => [
        'name'        => 'My CRM',
        'version'     => '1.0.0',
        'description' => 'Sends each message to My CRM.',
        'icon'        => remaily_logo( 'my-crm' ),
        'color'       => '#eef4ff',
        'settings'    => 'integrations',
    ],
] );

add_filter( 'remaily_logos', fn( $logos ) => $logos + [ 'my-crm' => MY_PATH . 'assets/my-crm.svg' ] );
add_action( 'remaily_addon_init_my-crm', [ My_Crm::class, 'init' ] );
Was this article helpful?