Newsletter Integrations

Base Newsletter Action Class

Ninja Forms THREE comes with a Base Newsletter Action Class, NF_Abstracts_ActionNewsletter, which should be extended by newsletter integrations and includes support for basic newsletter action settings.

The basic newsletter action settings include a list select setting and a dynamic number of field mapping settings, conditionally displayed based on the selected list.

For this functionality to be inherited, the base class requires the get_lists() method, which is used to dynamically create list selector options, as well as field mapping settings for each list.

Screenshot 2016-01-28 13.08.27

The get_lists() method should return an array of list options, each with an array of field options.

<?php
final class NF_Example_Actions_Newsletter extends NF_Abstracts_ActionNewsletter {
// …
protected function get_lists()
{
return array(
array(
'value' => 1,
'label' => 'One',
'fields' => array(
array(
'value' => 'one',
'label' => __( 'Field One', 'ninja-forms-mail-chimp' )
),
)
),
);
}
}

Refreshable List and List Fields

In addition to dynamically creating list selector options, the Base Newsletter Action Class utilizes the get_lists() method with a WordPress AJAX Action to re-populate the select options within the builder. The base class also provides basic caching functionality for getting lists and dumps the cache when updating from within the builder.

newsletter-refresh

Newsletter Opt-In Field

Coming Soon