WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Easy MailChimp Forms

Easy MailChimp Forms allows you to painlessly add MailChimp sign up forms to your WordPress site and track user activity with interactive reports.

Developer Docs.

Text Domain

Name:

yikes-inc-easy-mailchimp-extender

Description: 90% of the plug-in is localized and ready for translation. This means that you can manipulate text using the provided text domain, using a gettext filter.

Accepted Parameters: N/A

Example: This example will alter text on the admin dashboard on the manage lists page.

<?php
    /**
    * Change Specific Test on the 'Manage List Forms' page.
    *
    */
    function theme_change_comment_field_names( $translated_text, $text, $domain ) {

      switch ( $translated_text ) {

        case 'Your Lists' :

          $translated_text = __( 'MailChimp Lists', 'yikes-inc-easy-mailchimp-extender' );
          break;

        case 'Save Form Settings' :

          $translated_text = __( 'Save Form', 'yikes-inc-easy-mailchimp-extender' );
          break;

        case 'Create a Form For This List' :

          $translated_text = __( '<== Import This List', 'yikes-inc-easy-mailchimp-extender' );
          break;

      }

        return $translated_text;
    }
    add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 );
?>


Hooks

Hook Name:

yks_mc_before_form_$formID

Description: Used to place content before a specific MailChimp form. Use the form id to specify which form to place text before.

Accepted Parameters: N/A

Example: This example will print out a thank you message before a specific form.

<?php
    /**
    * Function to add text before the form with ID '0b071c0bd1'
    * You can get form ID's from the 'MailChimp List' page
    */
    function custom_before_form_action() {
        echo '<p>Thanks for checking out our mailing list. Fill out the form below to get started!</p>';
    }
    add_action( 'yks_mc_before_form_0b071c0bd1' , 'custom_before_form_action' );
?>

Note: in our add_action call we add the specific form ID to target a single form.


Hook Name:

yks_mc_after_form_$formID

Description: Used to place content after a specific MailChimp form. Use the form id to specify which form to place text after.

Accepted Parameters: N/A

Example: This example will print out a disclaimer message after a specific form._

<?php
    /**
    * Function to add text after the form with ID '0b071c0bd1'
    * You can get form ID's from the 'MailChimp List' page
    */
    function custom_after_form_action() {
        echo '<p><em>Your information is for internal use only, and will never be shared with or sold to anyone.</em></p>';
    }
    add_action( 'yks_mc_after_form_0b071c0bd1' , 'custom_after_form_action' );
?>

Note: in our add_action call we add the specific form ID to target a single form.


Hook Name:

yks_mc_before_form

Description: Used to place content before all MailChimp Forms.

Accepted Parameters: N/A

Example:

<?php
    /**
    * This example will print out a disclaimer to the user,
    * above all MailChimp forms. 
    */
    function custom_before_all_forms_action() {
        echo '<p><em>Your information is for internal use only, and will never be shared with or sold to anyone.</em></p>';
    }
    add_action( 'yks_mc_before_form' , 'custom_before_all_forms_action' );
?>


Hook Name:

yks_mc_after_form

Description: Used to place content after all MailChimp Forms.

Accepted Parameters: N/A

Example:

<?php
    /**
    * This example will print out a disclaimer to the user,
    * below all MailChimp forms. 
    */
    function custom_after_all_forms_action() {
        echo '<p><em>Your information is for internal use only, and will never be shared with or sold to anyone.</em></p>';
    }
    add_action( 'yks_mc_after_form' , 'custom_after_all_forms_action' );
?>


Filters

Filter Name:

yikes_mc_field_label

Accepted Parameters:

$label

Parameter Info:

$label = the text of the field label you would like to alter.

Description: The following example will change the default 'Email Address' label to 'Email!'

Example: This example will alter the 'Email Address' field label, and return 'Email!'

<?php
    /**
    * This example will alter the 'Email Address' field label, and return a 
    * new custom label name ('Email!')
    * anything else falls under 'default' and returns the un-altered label
    */
    function alter_mailchimp_field_labels( $label ) {

        switch ( $label ) {
            default :
                echo $label;
            break;
            
            case 'Email Address': // text of the existing label
                echo 'Email!'; // new email label text
            break;
        }
    }
    add_filter( 'yikes_mc_field_label' , 'alter_mailchimp_field_labels' );
?>


Filter Name:

yks_mailchimp_user_role

Accepted Parameters:

$capability

Parameter Info:

$capability = the lowest capability allowed to access the administration pages. defaults to 'manage_options' (admins).

Description: The following example will allow editors to access the YIKES MailChimp administration pages on the dashboard.

Example: The following example will allow editors to access the YIKES MailChimp administration pages on the dashboard.

<?php
    /**
    * This example will allow editors to access the YIKES MailChimp administration pages
    * If you would like authors or another user role to be able to access the admin  pages, you
    * must set this to the lowest capability allowed. ( check : http://codex.wordpress.org/Roles_and_Capabilities for role capabilities )
    * <em>note: for authors, you would use the 'publish_posts' capability.</em>
    */
    function yikes_mailchimp_allow_editors( $capability ) {
        $capability = 'edit_others_pages';
        return $capability;
    }
    add_filter( 'yks_mailchimp_user_role' , 'yikes_mailchimp_allow_editors' );
?>


Filter Name:

yikes_mc_get_form_data

Accepted Parameters:

$Form_ID

and $merge_variables

Parameter Info:

$Form_ID = the ID of the specific MailChimp Form ( can be retrieved from the 'MailChimp Forms > Manage List Forms' menu ).
$merge_variables = a multi-dimensional array containing all user entered data being sent to the MailChimp API (The email, first name, last name etc. will be contained here).

Description: Used to catch user data, from all forms, before it gets sent to the mailchimp API. Useful when you want to manipulate data before being sent to the MailChimp API or if you'd like to use the entered data locally.

Example: This example will catch the user submitted data, of all forms, store the users firstname in a variable and then update the current logged in user firstname profile field with the value in the First Name MailChimp field.

<?php
    /**
    * This example will catch the user submitted data, of all forms, store the users firstname in a variable and then update
    * the current logged in user firstname profile field with the value in the First Name MailChimp field. 
    */
    function catch_user_data( $form_ID, $merge_variables ) {
      // if the user is logged in
      if ( is_user_logged_in() ) {

        // get the logged in user id
        $user_id = get_current_user_id();

         // if the first name field is set
         if ( isset( $merge_variables['FNAME'] ) ) { 

         // update logged in users first name with the provided name in MC form
         wp_update_user( array( 'ID' => $user_id, 'first_name' => $merge_variables['FNAME'] ) );

         // can be used for any of the fields in the form + any fields in the user profile
         }

      }
    }
    add_filter( 'yikes_mc_get_form_data' , 'catch_user_data', 10, 2 );
?>


Filter Name:

yikes_mc_user_already_subscribed

Accepted Parameters:

$errorMessage

, $update_user_link and $email

Parameter Info:

$errorMessage = the error message returned by the MailChimp API. By Default : "email@domain.com is already subscribed to the list."
$update_user_link = the link that will re-submit the form to update the current users info. Default link text : "Update My Info"
$email

= the email address provided in the Email field

Description: Used to display a custom error message back to the user, when a user attempts to subscribe to a list they already exist on.

Example: The following example will alter the error returned from the MailChimp API. Useful when you would like to provide a more custom error message. The 'Update' link will re-submit the form using the 'update_existing' parameter to update the current users profile.

<?php
    /**
    * This example will return a custom error message to the user when they attempt to subscribe to 
    * a list they already exist on. The following will show something similar "Sorry, John@johnsmith.com is already subscribed to this list. Please Update My Information."
    */
    function custom_user_already_subscribed_error( $errorMessage , $update_user_link , $email ) {
        $errorMessage = 'Sorry, ' . $email . ' is already subscribed to this list.';
        $errorMessage .= str_replace( 'Update My Info.' , 'Please Update My Information' , $update_user_link );
        return $errorMessage;
    }
    add_filter( 'yikes_mc_user_already_subscribed' , 'custom_user_already_subscribed_error' , 10 , 3 );
?>


Filter Name:

yikes_mc_subscriber_update_message

Accepted Parameters:

$success_message

Parameter Info:

$success_message = the success message to be displayed to the user, defaults to "Thanks, your information has been successfuly updated."

Description: Used to alter the success message returned when a user updates their account information for a given list

Example: The following example will alter success message displayed back to the user after they have updated their account information for a given list. Defualts to : "Thanks, your information has been successfuly updated."

<?php
    /**
    * The following example will alter the success message when a user re-submits 
    * the form data to update their information for a given form
    */
    function custom_resubmit_info_message( $success_message ) {
        $success_message = "Thanks for updating your info! You're so awesome!";
        return $success_message;
    }
    add_filter( 'yikes_mc_subscriber_update_message' , 'custom_resubmit_info_message' , 10 );
?>


Filter Name:

yks_redirect_add_post_types

Accepted Parameters:

$post_array

Parameter Info:

$post_array = an array of post type names that you would like to be included into the drop down as a redirect option on the manage list page

Description: Use this filter to add any number of custom post types to the redirect dropdown

Example: The following example will add any and all posts with the custom post type 'portfolio' to the redirect dropdown

<?php
    /**
    * This example will add the custom post type 'portfolio' to the
    * redirect dropdown on the manage list forms page   
    */
    function add_portfolio_post_type_to_yikes_redirect_dropdown( $post_array ) {
        $post_array[] = 'portfolio';
        return $post_array;
    }
    add_filter( 'yks_redirect_add_post_types' , 'add_portfolio_post_type_to_yikes_redirect_dropdown' );
?>


Filter Name:

yikes_mailchimp_default_value_tag

Accepted Parameters:

$custom_tag_array

Parameter Info:

$custom_tag_array = an array of custom default tags. eg: array( '{custom_default_tag_1}' , '{custom_default_tag_2}' );

Description:

Note: if you're trying to set up custom default value tags, you'll want to use this filter as we'll as the one directly below it (yikes_mailchimp_process_default_value_tag). This filter adds your custom tag to the array, the yikes_mailchimp_process_default_value_tag filter processes the tag and replaces it with specific data.

Using this filter you can add new default value tags to the accepted tags. Any tags that you setup with this filter will appear in the list of selectable tabs to populate the default value field. The default value tags available to use out of the box are : * {post_title} - populates the field with the current page or post title that the user was on when they subscribed to the form. * {post_id} - populates the field with the current page or post ID that the user was on when they subscribed to the form. * {page_url} - populates the field with the current page URL that the user was on when they subscribed to the form. * {blog_name} - populates the field with the current blog name. Very useful for multi-site installations, when tracking which blog the user has signed up from is crucial to your marketing efforts. * {user_logged_in} - populates the field with with a dynamic value based on weather the user is logged in or not. When the user is logged in when signing up, the field populates with "User Logged In". If the user is not logged in, "Guest".

Example: The following example will add two new default value tags to the accepted default value tags array list, {new_custom_tag} and {new_custom_tag_2}.

<?php
    /**
    * This example will add two new user defined tags to the list of accepted default value tags array list
    * - note, this will only add your tags to the the list. use the next function to parse the tag and return some value
    **/
    function custom_yikes_mailchimp_default_value_tag( $custom_tag_array ) {
        $custom_tag_array = array( '{new_custom_tag}' , '{new_custom_tag_2}' );
        return $custom_tag_array;
    }
    add_filter( 'yikes_mailchimp_default_value_tag' , 'custom_yikes_mailchimp_default_value_tag' , 10 );
?>


Filter Name:

yikes_mailchimp_process_default_value_tag

Accepted Parameters:

$field

Parameter Info:

$field = the $field variable is a serialized array of data for the specific field. The array includes things such as the name, default value etc.

Description:

***Note: if you're trying to set up custom default value tags, you'll want to use this filter as we'll as the one directly above it (yikes_mailchimp_default_value_tag). This filter is used to parse your code and return a value to the field. Use this in conjunction with yikes_mailchimp_default_value_tag.

You'll use this filter to parse the custom default value tag you set up in the filter directly above this one (yikes_mailchimp_default_value_tag). Here you can perform all sorts of complex queries and functions to pull specific user data, page data, site data or anything else you can image.

Example: The following example will add two new default value tags to the accepted default value tags array list, {new_custom_tag} and {new_custom_tag_2}.

<?php
    /**
    * You can use the following function to process the custom default value tag into some useful data
    * ( note : you must pass in your new default custom tags using the provided yikes_mailchimp_default_value_tag filter (see example above ) )
    * ---------------------------------------------------------------------------------------------------------
    * Example #1 : Converts {new_custom_tag} into the users display name
    * Example #2 : Converts {new_custom_tag_2} into the referral page ( used to track how users landed on this page )
    **/
    function process_custom_yikes_mailchimp_default_value_tag( $field ) {
        switch ( $field['default'] ) {
            // convert {new_custom_tag} into usable data
            case '{new_custom_tag}': 
                global $current_user;
                // get current user info.
                get_currentuserinfo();
                // set this custom default tag to the users display name
                $default_value = $current_user->display_name;
                break;
                
            // convert {new_custom_tag} into usable data
            case '{new_custom_tag_2}': 
                $default_value = $_SERVER["HTTP_REFERER"];
                break;
                
            default:
                $default_value = $field['default'];
                break;
        }
        // return the default field value
        return $default_value;
    }
    add_filter( 'yikes_mailchimp_process_default_value_tag' , 'process_custom_yikes_mailchimp_default_value_tag'  , 10 );
?>


Filter Name:

yikes_mc_get_form_data_$formID

Accepted Parameters:

$merge_variables

Parameter Info:

$merge_variables = a multi-dimensional array containing all user entered data being sent to the MailChimp API (The email, first name, last name etc. will be contained here).

Description: Used to catch user data, of a specific form, before it gets sent to the mailchimp API. Useful when you want to manipulate data before being sent to the MailChimp API or if you'd like to use the entered data locally.

Example: This example will catch the user submitted data from a specific form, store the users firstname in a variable and then update the current logged in user firstname profile field with the value in the First Name MailChimp field.

<?php
    /**
    * This example will catch the user submitted data, store the users firstname in a variable and then update
    * the current logged in user firstname profile field with the value in the First Name MailChimp field. 
    * This catches data from ALL forms being submitted.
    */
    function catch_user_data_from_specific_form( $merge_variables ) {
      // if the user is logged in
      if ( is_user_logged_in() ) {

        // get the logged in user id
        $user_id = get_current_user_id();

         // if the first name field is set
         if ( isset( $merge_variables['FNAME'] ) ) { 

         // update logged in users first name with the provided name in MC form
         wp_update_user( array( 'ID' => $user_id, 'first_name' => $merge_variables['FNAME'] ) );

         // can be used for any of the fields in the form + any fields in the user profile
         }

      }
    }
    add_filter( 'yikes_mc_get_form_data_3d13f0f784' , 'catch_user_data_from_specific_form', 10, 2 );
?>

Customizing Templates Using Filters

Filter Name:

yks_mc_template_header

Description: Use this filter to alter the header text in any of the bundled sign up templates.

Example: The following will alter the header text in any of the bundled sign up forms. In the 'Clean Blue' template, this will change 'Sign Up Now' in the header, to 'Sign Up Below'.

<?php
    /**
    * The following example will alter the header text in any the bundled template
    * from 'Sign Up Now' to 'Sign Up Below'
    */
    function yks_easy_mailchimp_custom_template_header_text() {
        return 'Sign Up Below';
    }
    add_filter( 'yks_mc_template_header' , 'yks_easy_mailchimp_custom_template_header_text' , 10 );
?>


Filter Name:

yks_mc_template_sub_text

Description: Use this filter to alter the sub text in any of the bundled sign up templates. The sub text is the text below the header, and above the form. eg: "Sign up for mailing list and receive new posts directly to your inbox."

Example: The following will alter the sub text in any of the bundled sign up forms. In the 'Clean Blue' template, this will change "Sign up for mailing list and receive new posts directly to your inbox." to "Sign up for our amazing mailing list today!".

<?php
    /**
    * The following example will alter the sub text in any the bundled template
    * from 'Sign up for mailing list and receive new posts directly to your inbox.' to 'Sign up for our amazing mailing list today!'
    */
    function yks_easy_mailchimp_custom_template_subtext() {
        return 'Sign up for our amazing mailing list today!';
    }
    add_filter( 'yks_mc_template_sub_text' , 'yks_easy_mailchimp_custom_template_subtext' , 10 );
?>


Filter Name:

yks_mc_template_footer_text

Description: Use this filter to alter the footer text in any of the bundled sign up templates. The footer text is the text below the form eg: "We promise never to share or sell any of your personal information."

Example: The following will alter the sub text in any of the bundled sign up forms. In the 'Clean Blue' template, this will change "We promise never to share or sell any of your personal information." to "Your information will remain private at all times.".

<?php
    /**
    * The following example will alter the sub text in any the bundled template
    * from 'Sign up for mailing list and receive new posts directly to your inbox.' to 'Sign up for our amazing mailing list today!'
    */
    function yks_easy_mailchimp_custom_template_footer_text() {
        return 'Your information will remain private at all time.';
    }
    add_filter( 'yks_mc_template_footer_text' , 'yks_easy_mailchimp_custom_template_footer_text' , 10 );
?>


Helper Functions

Description: These functions are defined inside of the Easy MailChimp plugin and they exist to help test and view the user data that is being submitted by the user through the MailChimp form. These functions will prevent the default form functionality, so no user data will be sent to MailChimp while testing.

These functions should be used in conjunction with the yikes_mc_get_form_data or the yikes_mc_get_form_data_$formID filters. Whatever data the user has provided will be returned for viewing.

Provided Functions

yks_mc_print_user_data( $form_ID, $merge_variables );

and yks_mc_dump_user_data( $form_ID, $merge_variables );

How to Use Print User Data

<?php
    /**
    * This example will return all of the submitted 
    * user data In a nice readable format
    */
    function print_user_data_from_form( $form_ID, $merge_variables ) {
        if( class_exists( 'yksemeBase' ) ) {
            $yikes_easy_mailchimp = new yksemeBase();
        }
        $yikes_easy_mailchimp->yks_mc_print_user_data( $form_ID, $merge_variables );
    }
    add_filter( 'yikes_mc_get_form_data' , 'print_user_data_from_form', 10, 2 );
?>

Dump User Data

<?php
    /**
    * This example will dump all of the submitted 
    * user data, so you can see the full array of data
    * being returned
    */
    function dump_user_data_from_form( $form_ID, $merge_variables ) {
        if( class_exists( 'yksemeBase' ) ) {
            $yikes_easy_mailchimp = new yksemeBase();
        }
        $yikes_easy_mailchimp->yks_mc_dump_user_data( $form_ID, $merge_variables );
    }
    add_filter( 'yikes_mc_get_form_data' , 'dump_user_data_from_form', 10, 2 );
?>

Requires: 3.0 or higher
Compatible up to: 4.1.1
Last Updated: 2015-3-3
Active Installs: 10,000+

Ratings

4.5 out of 5 stars

Support

37 of 42 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,4,4 100,2,2 100,1,1
100,1,1
0,2,0 100,1,1 100,2,2
100,1,1
0,1,0
100,3,3 100,4,4
100,4,4
100,3,3
100,2,2 100,2,2
100,1,1
100,1,1 100,2,2 100,1,1 100,2,2 100,5,5 67,3,2 100,2,2 100,2,2 100,2,2 100,2,2 100,1,1 100,1,1
100,2,2 100,1,1 100,1,1
100,2,2 100,1,1 100,2,2 100,2,2 100,1,1 100,2,2 100,1,1 100,1,1
100,1,1 100,1,1
75,4,3 100,1,1 100,4,4 100,1,1 100,1,1
100,2,2 100,1,1