-
Notifications
You must be signed in to change notification settings - Fork 27
Developer Docs
- yikes-mailchimp-form-title-FORM_ID
- yikes-mailchimp-form-description-FORM_ID
- yikes-mailchimp-redirect-timer
- yikes-mailchimp-before-submission
- yikes-mailchimp-before-submission-FORM_ID
- yikes-mailchimp-after-submission
- yikes-mailchimp-after-submission-FORM_ID
- yikes-mailchimp-user-role-access
Description
This filter is executed when the specified MailChimp form is rendered on the front end of your site and can be used to alter the title of a given form.
Usage
Applies to a specific form.
apply_filters( 'yikes-mailchimp-form-title-'.$form_id , apply_filters( 'the_title' , $form_name ) );Parameters
- $form_title
The form title of the specified form to alter.
Examples
This example will alter the form title on the front end of your site, for the MailChimp form with id 1 only.
function alter_mailchimp_form_title( $form_title ) {
$form_title = 'New Form Title';
return $form_title;
}
add_action( 'yikes-mailchimp-form-title-1' , 'alter_mailchimp_form_title' );Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_shortcode.php.
Description
This filter is executed when the specified MailChimp form is rendered on the front end of your site and can be used to alter the description of a given form.
Usage
Applies to a specific form.
apply_filters( 'yikes-mailchimp-form-description-'.$form_id , $form_description );Parameters
- $form_description
The form description of the specified form to alter.
Examples
This example will alter the form description on the front end of your site, for the MailChimp form with id 1 only.
function alter_mailchimp_form_description( $form_description ) {
$form_description = 'Please enter your email address and name below to sign up for our mailing list.';
return $form_description;
}
add_action( 'yikes-mailchimp-form-description-1' , 'alter_mailchimp_form_description' );Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_shortcode.php.
Description
This filter is executed after a successful form submission, and is only fired off if a redirection is set on the form.
Usage
Applies to all forms, both ajax and non-ajax.
apply_filters( 'yikes-mailchimp-redirect-timer' , $redirect_time );Parameters
- $redirect_time (in milliseconds)
The amount of time before redirecting a user to the specified page (in milliseconds).
Examples
This example will increase the amount of time before a user is redirected from 1500ms (default - 1.5 seconds) to 3000ms (3 seconds), for all forms.
function increase_redirect_time( $redirect_time ) {
$redirect_time = 3000; // must pass in milliseconds, not seconds (1s = 1000ms)
return $redirect_time;
}
add_action( 'yikes-mailchimp-redirect-timer' , 'increase_redirect_time' );Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_shortcode.php.
Description
This filter is executed after a successful form submission, and is fired off right before the data is sent over to MailChimp. This filter can be used to dynamically populate any of the fields, visible or not, with user data or any other data you see fit.
Usage
Applies to all forms, both ajax and non-ajax.
apply_filters( 'yikes-mailchimp-before-submission' , $merge_variables );Parameters
- $user_data
An array of all of the user provided data when the form was submit, including interest groups. eg:
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => User First Name
[optin_time] => 2015-05-07 21:21:25
)Examples
This example will populate the first name field with the current users first name, only if they are logged in.
function populate_user_firstname( $user_data ) {
if( is_user_logged_in() ) {
get_currentuserinfo();
$user_data['FNAME'] = $current_user->user_firstname;
}
return $user_data;
}
add_filter( 'yikes-mailchimp-before-submission' , 'populate_user_firstname' );Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_submission.php & process_form_submission_ajax.php
Description
This filter is executed after a successful form submission, and is fired off right before the data is sent over to MailChimp. This filter can be used to dynamically populate any of the fields, visible or not, with user data or any other data you see fit.
Usage
Applies to a specified form, both ajax and non-ajax.
apply_filters( 'yikes-mailchimp-before-submission-'.$form , $merge_variables );Parameters
- $user_data
An array of all of the user provided data when the form was submit, including interest groups. eg:
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => User First Name
[optin_time] => 2015-05-07 21:21:25
)after the filter below is executed, the result would then be (assuming the current logged in users first name is John):
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => John
[optin_time] => 2015-05-07 21:21:25
)Examples
This example will populate the first name field with the current users first name, only if they are logged in. This will only effect the form with id 1.
function populate_user_firstname( $user_data ) {
if( is_user_logged_in() ) {
get_currentuserinfo();
$user_data['FNAME'] = $current_user->user_firstname;
}
return $user_data;
}
add_filter( 'yikes-mailchimp-before-submission-1' , 'populate_user_firstname' );after the filter below is executed, the result would then be (assuming the current logged in users first name is John):
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => John
[optin_time] => 2015-05-07 21:21:25
)Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_submission.php & process_form_submission_ajax.php
Description
This filter is executed after a successful form submission, and is fired off directly after the data is successfully sent over to MailChimp. This filter can be used to store submitted user data in the database, used to create new users who any other appropriate functionality.
Usage
Applies to all forms.
do_action( 'yikes-mailchimp-after-submission' , $merge_variables );Parameters
- $user_data
An array of all of the user provided data when the form was submit, including interest groups. eg:
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => User First Name
[optin_time] => 2015-05-07 21:21:25
)Examples
This example will create a new subscriber user each time the form is filled out, as long as the username isn't already taken. The following function should be tightened up for production use, this is an example.
function create_user_on_mailchimp_submission( $user_data ) {
$username = $user_data['FNAME'];
$password = generateUserPassword();
$email = $user_data['EMAIL'];
if (username_exists( $username ) == null && email_exists( $email ) == false) {
$user_id = wp_create_user( $username, $password, $email );
$user = get_user_by( 'id', $user_id );
$user->add_role( 'subscriber' );
// trigger registration email
wp_new_user_notification( $user_id, $password );
}
}
add_action( 'yikes-mailchimp-after-submission' , 'create_user_on_mailchimp_submission' );and for anyone who would like to use the above function, you'll need the generateUserPassword(); function used above.
function generateUserPassword($length = 12) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_submission.php & process_form_submission_ajax.php
Description
This filter is executed after a successful form submission, and is fired off directly after the data is successfully sent over to MailChimp. This filter can be used to store submitted user data in the database, used to create new users who any other appropriate functionality.
Usage
Applies to a specified form.
do_action( 'yikes-mailchimp-after-submission-'.$form , $merge_variables );Parameters
- $user_data
An array of all of the user provided data when the form was submit, including interest groups. eg:
Array (
[EMAIL] => user-email@gmail.com
[FNAME] => User First Name
[optin_time] => 2015-05-07 21:21:25
)Examples
This example will create a new subscriber user each time the form is filled out, as long as the username isn't already taken. The following function should be tightened up for production use, this is an example.
function create_user_on_mailchimp_submission( $user_data ) {
$username = $user_data['FNAME'];
$password = generateUserPassword();
$email = $user_data['EMAIL'];
if (username_exists( $username ) == null && email_exists( $email ) == false) {
$user_id = wp_create_user( $username, $password, $email );
$user = get_user_by( 'id', $user_id );
$user->add_role( 'subscriber' );
// trigger registration email
wp_new_user_notification( $user_id, $password );
}
}
add_action( 'yikes-mailchimp-after-submission-1' , 'create_user_on_mailchimp_submission' );and for anyone who would like to use the above function, you'll need the generateUserPassword(); function used above.
function generateUserPassword($length = 12) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in process_form_submission.php & process_form_submission_ajax.php
Description
This filter is allows you to alter who can access Easy MailChimp by Yikes Inc., by capability.
Usage
Alters who can access Easy MailChimp in the dashboard.
apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ), Parameters
- $capability
The minimum capability required to access the dashboard page, edit forms, alter account info etc.
Examples
This example will allow editors and admins to access the Easy MailChimp menu item in the dashboard. (Because both user roles have the cabaility 'delete_others_pages'.
function alter_yikes_easy_mailchimp_access( $capability ) {
$capability = 'delete_others_pages'; // allow editors & admins to access Easy MailChimp
return $capability;
}
add_action( 'yikes-mailchimp-user-role-access' , 'alter_yikes_easy_mailchimp_access' );Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in class-yikes-inc-easy-mailchimp-extender-admin.php_ & process_form_shortcode.php
Home | About YIKES | Setup | Plugin Usage | Developer Documentation | Support | Copyright © 1996-2015 YIKES Inc.