Primary

API

Groups Newsletters provides lots of sensible WordPress actions and filters that you can use to customize the system. It leverages custom post types and taxonomies to provide a system that any developer who is familiar with those concepts in WordPress can use, to provide a customized solution for their client.

Constants

GROUPS_NEWSLETTERS_RECAPTCHA_SECRET_KEY

The constant can be used to define the ReCAPTCHA secret key in your site’s wp-config.php.

Example:

define( 'GROUPS_NEWSLETTERS_RECAPTCHA_SECRET_KEY', 'xxxxxxxxxxxxxx' );

GROUPS_NEWSLETTERS_RECAPTCHA_SITE_KEY

The constant can be used to define the ReCAPTCHA site key in your site’s wp-config.php.

Example:

define( 'GROUPS_NEWSLETTERS_RECAPTCHA_SITE_KEY', 'xxxxxxxxxxxxxx' );

Actions

groups_newsletters_user_subscribed

This action is invoked after a user has subscribed to newsletters.

Parameters

  • $user_id int The ID of the user that subscribed

groups_newsletters_user_unsubscribed

This action is invoked after a user has unsubscribed from newsletters.

Parameters

  • $user_id int The ID of the user that unsubscribed

groups_newsletters_campaign_status_updated

This action is invoked after a campaign status changes.

Parameters

  • $new_status string The campaign new status
  • $current_status string The campaign current status
  • $post_id int The campaign ID

groups_newsletters_subscriber_activated

This action is invoked when a subscription is activated.

Parameters

  • $subscriber object The subscriber data object that activated the subscription with properties:
  1. subscriber_id int The subscriber ID
  2. email string The subscriber email
  3. status bool The subscriber status
  4. subscribed datetime The date and time of the subscription activation
  5. hash string The subscriber unique hash key

groups_newsletters_subscriber_cancelled

This action is invoked when a subscription is cancelled.

Parameters

  • $subscriber object The subscriber data object that cancelled the subscription with properties:
  1. subscriber_id int The subscriber ID
  2. email string The subscriber email
  3. status bool The subscriber status
  4. subscribed datetime The date and time of the subscription cancellation
  5. hash string The subscriber unique hash key

groups_newsletters_deactivate

This action is invoked after the plugin is deactivated.

Parameters

  • $network_wide boolean If the plugin is deactivated network-wide

Filters

groups_newsletters_get_subscribe_text

This filter allows to modify the label text for the subscription form.

Parameters

  • $text string The text used in the label, default value ‘Subscribe to our Newsletters’

Returns

  • string

groups_newsletters_newsletter_email_header

This filter allows to use custom header in the newsletter email.

Parameters

  • $header string The string to use for the header, default is empty string

Returns

  • string

groups_newsletters_newsletter_email_content

This filter allows to adjust the content in the newsletter email.

Parameters

  • $header string The string to use for the content, default is the render content based on email template

Returns

  • string

groups_newsletters_newsletter_email_footer

This filter allows to use custom footer in the newsletter email.

Parameters

  • $footer string The string to use for the footer, default is an empty string

Returns

  • string

groups_newsletters_newsletter_stories_orderby

This filter allows to change the order of stories in a newsletter.

Parameters

  • $orderby array The array with order by parameters and keys
  1. menu_order, default value ‘ASC’
  2. date, default value ‘DESC’

Returns

  • array

groups_newsletters_campaign_status_update

This filter allows to change the status of a newsletter campaign.

Parameters

  • $new_status string The new status to set for the campaign, allowed values are ‘pending’, ‘on-hold’, ‘running’, ‘executed’
  • $current_status The current status of the campaign
  • $post_id int The campaign ID

Returns

  • string $new_status

groups_newsletters_register_form_opt_in

Allows to change the opt-in form HTML. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $register_form string The HTML for the form

Returns

  • string

groups_newsletters_activation_tokens

This filter should return the values for the tokens used in subscription activation emails, when subscribing to newsletters. This filter can be used to modify and add tokens.

Parameters

  • $tokens array of string indexed by token keys
  1. activation_url That consists of the subscriber activation hash, the subscriber email address and the site URL
  2. email The subscriber email
  3. site_url The site URL
  4. site_title The site title

Returns

  • string

groups_newsletters_activation_subject

Allows to change the subject of subscription activation email.

Parameters

  • $subject string The text to use for the subject, default text is ‘Please confirm your subscription’

Returns

  • string

groups_newsletters_activation_message

Allows to change the message of subscription activation email. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $message string The HTML message used

Returns

  • string

groups_newsletters_subscribe_form_prologue

Allows to add content in the subscription form right after the opening <form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_subscribe_form_epilogue

Allows to add content in the subscription form right before the closing </form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_subscribe_form_output

Allows to modify the subscription form output. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The form markup

Returns

  • string

groups_newsletters_unsubscribe_form_prologue

Allows to add content in the unsubscription form right after the opening <form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_unsubscribe_form_epilogue

Allows to add content in the unsubscription form right before the closing </form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_unsubscribe_form_output

Allows to modify the unsubscription form output. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The form markup

Returns

  • string

groups_newsletters_user_subscribe_form_prologue

Allows to add content in the user subscription form right after the opening <form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_user_subscribe_form_epilogue

Allows to add content in the user subscription form right before the closing </form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_user_unsubscribe_form_prologue

Allows to add content in the user unsubscription form right after the opening <form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_user_unsubscribe_form_epilogue

Allows to add content in the user unsubscription form right before the closing </form> tag. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added

Returns

  • string

groups_newsletters_cancellation_tokens

This filter should return the values for the tokens used in subscription cancellation emails, when unsubscribing from newsletters. This filter can be used to modify and add tokens.

Parameters

  • $tokens array of string indexed by token keys
  1. cancellation_url That consists of the subscriber activation hash, the subscriber email address and the site URL
  2. email The subscriber email
  3. site_url The site URL
  4. site_title The site title

Returns

  • string

groups_newsletters_cancellation_subject

Allows to change the subject of subscription cancellation email.

Parameters

  • $subject string The text to use for the subject

Returns

  • string

groups_newsletters_cancellation_message

Allows to change the message of subscription deactivation email. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $message string The HTML message used

Returns

  • string

groups_newsletters_list_prologue

Allows to add content before the newsletters list. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added
  • $options array of string indexed by option keys
  1. show_count boolean Default value true
  2. orderby string One of the following options: name, slug, term_id, count, date, none. Default value name
  3. order string ASC or DESC, default value ASC
  4. show_option_none string Text message when there are no newsletters
  5. show_empty boolean Default value false
  6. per_page int Default value 10

Returns

  • string

groups_newsletters_list_content

Allows to modify the newsletters list content. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $content string The newsletters list
  • $options array of string indexed by option keys
  1. show_count boolean Default value true
  2. orderby string One of the following options: name, slug, term_id, count, date, none. Default value name
  3. order string ASC or DESC, default value ASC
  4. show_option_none string Text message when there are no newsletters
  5. show_empty boolean Default value false
  6. per_page int Default value 10

Returns

  • string

groups_newsletters_list_epilogue

Allows to add content after the newsletters list. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The content added
  • $options array of string indexed by option keys
  1. show_count boolean Default value true
  2. orderby string One of the following options: name, slug, term_id, count, date, none. Default value name
  3. order string ASC or DESC, default value ASC
  4. show_option_none string Text message when there are no newsletters
  5. show_empty boolean Default value false
  6. per_page int Default value 10

Returns

  • string

groups_newsletters_list_output

Allows to adjust the output of newsletters list container. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The newsletters list output
  • $options array of string indexed by option keys
  1. show_count boolean Default value true
  2. orderby string One of the following options: name, slug, term_id, count, date, none. Default value name
  3. order string ASC or DESC, default value ASC
  4. show_option_none string Text message when there are no newsletters
  5. show_empty boolean Default value false
  6. per_page int Default value 10

Returns

  • string

groups_newsletters_search_output

Allows to adjust the output of search form. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The search form output

Returns

  • string

groups_newsletters_get_search_form_add_story_post_type

Modify the search from to keep search among stories limited to the story post type.

Parameters

  • $enable boolean Default value true

Returns

  • boolean

groups_newsletters_get_search_form_info

Modify info text shown after the stories search form. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The text message, defaults to ”Searching in stories &hellip;’

Returns

  • string

groups_newsletters_get_search_form

Modify the stories search form. Use with caution as malformed HTML will corrupt the form displayed.

Parameters

  • $output string The form output

Returns

  • string

groups_newsletters_legacy_templates

Whether to enable the legacy templates, used in Groups Newsletters version 2.x.x.

Parameters

  • $enable boolean Default value false

Returns

  • boolean

Example: Add the following snippet to functions.php file of your active theme, to enable legacy templates.

add_filter( 'groups_newsletters_legacy_templates', '__return_true' );

groups_newsletters_template_base

Modify the templates base location. Please note that no trailing slash is needed.

Parameters

  • $output string Base location, defaults to ‘groups-newsletters’

Returns

  • string