dev-master
9999999-dev https://github.com/mrbobbybryant/omg-forms-mailchimpAn OMG Forms addon, which adds support for mailchimp forms.
GPL-2.0+
The Requires
An OMG Forms addon, which adds support for mailchimp forms.
A WordPress Forms Solution built specifically for Developers. This addon will send all form submissions to Mailchimp., (*1)
OMG Forms can be installed via composer., (*2)
$ composer require developwithwp/omg-forms
Once you have installed this package you will need to call Composer's autoloader if your project is not already., (*3)
if ( file_exists( get_template_directory() . '/vendor/autoload.php' ) ) { require( 'vendor/autoload.php' ); }
You are now ready to create your first form. OMG Forms comes with a helper method for creating new forms \OMGForms\Core\register_form()
., (*4)
This function expects an array of arguments similar to how register_post_type
expects an array of arguments., (*5)
To start lets define a very simple form., (*6)
$args = [ 'name' => 'mailchimp-form', 'redirect' => false, 'email' => false, 'form_type' => 'mailchimp', 'success_message' => 'Thank you!', 'list_id' => 'a16dff7b29', 'rest_api' => true, 'fields' => [ [ 'slug' => 'fname', 'label' => 'First Name', 'type' => 'text', 'required' => true ], [ 'slug' => 'lname', 'label' => 'Last Name', 'type' => 'text', 'required' => true ], [ 'slug' => 'email-address', 'label' => 'Email', 'type' => 'email', 'required' => true ] ] ];
As you can see the form allows for a lot of configuration at both the form and the field level., (*7)
Once you have defined a form, you can render it by calling display_form
., (*8)
echo \OMGForms\Core\display_form( 'mailchimp-form' );
For the Mailchimp addon to work you will need to ensure you provide a few key settings when registering your form.
1. form-type
must be set to mailchimp
2. rest_api
must be set to true
.
3. You must provide a valid list_id for the mailchimp list you wish to use. This can be found in the list settings dropdown in Mailchimp. Click on List name and campaign defaults.
4. First and Last Name fields should have a slug of fname
and lname
.
5. Must provide an email field with a slug of email-address
., (*9)
For more information about OMG Forms in general, please check out the base repo., (*10)
An OMG Forms addon, which adds support for mailchimp forms.
GPL-2.0+