WP Manifestindependent plugin directory
manifest / email / wpunewsletter

WP Utilities Newsletter

Allow subscriptions to a newsletter.

by Darklg · github.com/wordpressutilities/wpunewsletter · website

0stars
1forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/wordpressutilities/wpunewsletter/archive/refs/heads/main.zip

Declares an update source (https://github.com/WordPressUtilities/wpunewsletter), so updates arrive through the plugin's own updater.

Readme

WPU Newsletter

Allow subscriptions to a newsletter.

How to use

the_widget('wpunewsletter_form', array(
    'content_label' => __('Email', 'wpunewsletter'),
    'content_placeholder' => __('Your email address', 'wpunewsletter'),
    'content_button' => __('Register', 'wpunewsletter')
));

Available options

the_widget('wpunewsletter_form', array(
    /* Content */
    'content_label' => __('Email', 'wpunewsletter'),
    'content_placeholder' => __('Your email address', 'wpunewsletter'),
    'content_button' => __('Register', 'wpunewsletter'),
    'text' => '',

    /* Layout */
    'form_has_wrapper' => true,
    'fields_has_wrapper' => true,
    'main_field_have_wrapper' => true,
    'main_field_position' => 'before',
    'messages_over_form' => true,

    /* CSS classes */
    'form_id' => 'newsletter-form',
    'classes_form' => 'newsletter-form',
    'classes_mainfield' => '',
    'classes_fieldwrapper' => 'field',
    'classes_label' => 'newsletter-label',
    'classes_button' => 'cssc-button cssc-button--default',

    /* Extra fields */
    'hidden_fields' => array(),
    'extra_fields_values' => array(),

    /* Third-party lists */
    'mailchimp_list_id' => '',
    'brevo_list_id' => '',

    /* JS */
    'js_callback_before_submit' => ''
));

Extra fields

Add custom fields to the newsletter form via the wpunewsletter_extra_fields filter.

Supported types

text, email, url, checkbox, select, radio.

Example

add_filter('wpunewsletter_extra_fields', function ($fields) {
    $fields['firstname'] = array(
        'name' => 'First name',
        'type' => 'text',
        'required' => true,
        'placeholder' => 'John',
        'brevo_attribute' => 'FIRSTNAME'
    );
    $fields['civility'] = array(
        'name' => 'Civility',
        'type' => 'select',
        'required' => true,
        'placeholder' => '—',
        'options' => array(
            'MR' => 'Mr',
            'MRS' => 'Mrs'
        ),
        'brevo_attribute' => 'CIVILITY'
    );
    $fields['interest'] = array(
        'name' => 'Interest',
        'type' => 'radio',
        'options' => array(
            'sport' => 'Sport',
            'culture' => 'Culture',
            'tech' => 'Tech'
        )
    );
    return $fields;
});

Read the full README on GitHub →