Filters - Code Parrots

Knowledge Base

Filters

Article Last Updated: March 4, 2021

This is a list of all the available filters. Examples of using some of these filters can be found below.

  • `yikes-mailchimp-redirect-url` – Alter the URL of the page that the user will be redirected to on a successful submission. @params: $url, $form_id, $page_data
  • `yikes-mailchimp-filter-before-submission` and `yikes-mailchimp-filter-before-submission-{$form_id}` – Catch the merge variables before they get sent over to Mailchimp. @params: $merge_variables
  • `yikes-mailchimp-after-submission` and `yikes-mailchimp-after-submission-{$form_id}` – Catch the merge variables after they get sent over to Mailchimp. @params: $merge_variables
  • `yikes-mailchimp-international-phone-pattern` – Alter the regex pattern for acceptable international phone number formats. Default: `'[0-9,-,+]{1,}’` – @params: $regex_pattern
  • `yikes-mailchimp-us-phone-pattern` – Alter the regex pattern for acceptable US phone number formats. Default: `^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$` – @params: $regex_pattern
  • `yikes-mailchimp-zip-pattern` – Alter the zip code regex pattern. Default: `\d{5,5}(-\d{4,4})?` – @params: $regex_pattern
  • `yikes-mailchimp-process-default-tag` – Alter the default form field value for text fields. @params: $default_value
  • `yikes-mailchimp-{$merge_tag}-label` – Alter the specified form field’s or interest group’s label text. @params: $label
  • `yikes-mailchimp-{$merge_tag}-description` – Alter the specified form field’s or interest group’s description text (note: if targeting an interest group, it will be the group_id instead of the merge tag). @params: $description_content, $form_id.
  • `yikes-mailchimp-address-{$type}-label` – Alter the field sub-label text for a specific address field (e.g. addr1). @params: $label
  • `yikes-mailchimp-form-submit-button` – Alter the submit button to your liking. @params: $submit_button, $form_id
  • `yikes-mailchimp-form-submit-button-text` – Alter the submit button text. Default: `submit` – @params: $submit_button_text, $form_id
  • `yikes-mailchimp-form-submit-button-classes` – Add additional classes to the submit button for further styling. @params: $classes, $form_id
  • `yikes-mailchimp-form-container-class` – Add additional classes to the `<section>` element container that wraps the form. @params: $class_name, $form_id
  • `yikes-mailchimp-form-class` – Add additional classes to `<form>` element of your opt-in form. @params: $class_name, $form_id
  • `yikes-mailchimp-front-end-form-action-links` – Add custom front end action links alongside Edit Form, Customize Form etc. @params: $form_action_links, $form_id, $form_name
  • `yikes-mailchimp-custom-default-value-tags` – Define your own custom pre-defined tags to populate the default value fields with – these tags appear in the modal. @params: $pre_defined_tags_array
  • `yikes-mailchimp-parse-custom-default-value` – Process your custom default merge tag into a custom value to populate the form field with (note: Goes hand in hand with `yikes-mailchimp-custom-default-value-tags` filter). @params: $default_tag
  • `yikes-mailchimp-field-data` – Filter form field data such as placeholder, label, etc. @params: $field_array, $field, $form_id
  • `yikes-mailchimp-subscriber-count-value` – Alter the returned value for the total subscriber count of a given Mailchimp list. @params: $subscriber_count
  • `yikes-mailchimp-frontend-content` – Custom content filter for this plugin to prevent others from hooking in where not wanted.
  • `yikes-mailchimp-recaptcha-parameters` – Alter any of the possible reCAPTCHA shortcode parameters. @params: $recaptcha_parameter_array, $form_id
  • `yikes-mailchimp-preloader` – Add a custom preloader image. Default: WordPress’s wpspin_light.gif. @params: $url_to_spinner_gif
  • `yikes-mailchimp-update-email-subject` – Filter the subject line for the email that is generated and sent when a user needs to update their subscription info. @params: $email_subject
  • `yikes-mailchimp-update-email-content` – Filter the content of the email that is generated and sent when a user needs to update their subscription info. @params: $email_body
  • `yikes-mailchimp-success-response` – Alter *any* success response text. @params: $response_text, $form_id, $submitted_form_variables
  • `yikes-mailchimp-default-country-value` – Alter the default country selected in the country dropdown. Default: `US` – @params: $country_slug
  • `yikes-mailchimp-recaptcha-required-error` – Filter the error displayed back to the user when an error occurs during the reCAPTCHA submission process. @params: $error_text, $form_id
  • `yikes-mailchimp-sslverify` – Toggle sslverify on/off when attempting to validate your API key with the Mailchimp API servers. Default: `true` (on) – @params: $use_ssl
  • `yikes-mailchimp-success-double-optin-response` – Filter the “Success: Double opt-in” custom message. @params: $message, $form_id
  • `yikes-mailchimp-success-single-optin-response` – Filter the “Success: Single opt-in” custom message. @params: $message, $form_id
  • `yikes-mailchimp-success-resubscribed-response` – Filter the “Success: Re-subscriber” custom message. @params: $message, $form_id
  • `yikes-mailchimp-user-already-subscribed-link-text` – Filter the “Success: Re-subscriber with link to email profile update message” custom message. @params: $message, $form_id
  • `yikes-mailchimp-general-error-response` – Filter the “Error: General” custom message. @params: $message, $form_id
  • `yikes-mailchimp-user-already-subscribed-text` – Filter the “Error: Re-subscribers not permitted” custom message (note: this replaced `yikes-mailchimp-user-already-subscribed-error`). @params: $message, $form_id
  • `yikes-mailchimp-filter-groups-before-submission` and `yikes-mailchimp-filter-groups-before-submission-{$form_id}` – Filter the interest groups before they’re submitted. @params: $groups, $form_id
  • `yikes-mailchimp-address-2-required` – Change the address 2 field’s `required` value. Default: `”` (it is never required) – @params: $required, $form_id
  • `yikes-mailchimp-filter-subscribe-request` and `yikes-mailchimp-filter-subscribe-request-{$form_id}` – Filter all of the fields sent over to the Mailchimp API (not just the form fields). @params: $subscribe_body, $form_id
  • `yikesinc_eme_default_api_version` – Filter the API version. Default: `3.0` – @params: $version
  • `yikesinc_eme_api_url` – Filter the URL used for a request to the Mailchimp API. @params: $full_path, $path
  • `yikesinc_eme_api_user_agent` – Filter the user agent used in API request. @params: $user_agent
  • `yikesinc_eme_api_auth_headers` – Filter the authentication headers used in the API request. @params: $auth_headers, $api_version
  • `yikesinc_eme_api_headers` – Filter the headers used for a request to the Mailchimp API. @params: $headers, $path, $method, $params
  • `yikesinc_eme_api_timeout` – Filter the timeout (in *seconds*) used when sending an API request. Default: `15` @params: $timeout
  • `yikesinc_eme_api_args` – Filter the arguments used for a request to the Mailchimp API. @params: $args, $path, $method, $params

yikes-mailchimp-form-title

Description

This filter is used to change or alter the Mailchimp opt-in form titles globally, or on a per form basis.

Note: The shortcode parameter title=”1″ must be set. If you’re looking to add custom content before the form, consider using the yikes-mailchimp-before-form action hook.

Usage

The following is an example of how to hook in and filter the form title:

add_filter( 'yikes-mailchimp-form-title', 'your_function_name', 10, 2 );

Parameters

  • $form_title | String

The pre-defined form title of the MailChimo Opt-in form

  • $form_id | Integer

The ID of the Opt-in form, used to target forms on an individual basis

Examples

This example changes the form title of a specific form with ID 2.

function alter_mailchimp_form_title( $form_title, $form_id ) {
    if( $form_id == 2 ) {
        $form_title = 'New Form Title';
    }
    return $form_title;
}
add_filter( 'yikes-mailchimp-form-title', 'alter_mailchimp_form_title', 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in /public/partials/shortcodes/ process_form_shortcode.php

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-form-description

Description

This filter is used to change or alter the Mailchimp opt-in form description globally, or on a per form basis.

Usage

The following is an example of how to hook in and filter the form description:

add_filter( 'yikes-mailchimp-form-description', 'your_function_name', 10, 2 );

Parameters

  • $form_description | String

The pre-defined form description of the MailChimo Opt-in form

  • $form_id | Integer

The ID of the Opt-in form, used to target forms on an individual basis

Examples

This example changes the form description of a specific form with ID 2.

function alter_mailchimp_form_description( $form_description, $form_id ) {
    if( $form_id == 2 ) {
        $form_description = 'New form description.';
    }
return $form_description;
}

add_filter( 'yikes-mailchimp-form-description', 'alter_mailchimp_form_description', 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in /public/partials/shortcodes/ process_form_shortcode.php

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-redirect-timer

Description

This filter is used to alter the time before the user is redirected after they successfully submit a form. Note: Redirect must be set to true for this to have any effect.

Usage

The following is an example of how to hook in and filter the form title:

add_filter( 'yikes-mailchimp-redirect-timer', 'your_function_name', 10 );

Parameters

  • $delay_before_redirect | Integer (ms)

The default time to wait (ms) after a successful form submission before redirecting the user on to another page. (defaults to 1500 // 1000ms = 1s)

Examples

This example will increase the time from 1.5s to 5s before redirecting the user after the form has been submitted successfully.

/* Alter form redirection timer */

function alter_mailchimp_redirection_timer( $delay_before_redirect ) {
    $delay_before_redirect = 5000;
    return $delay_before_redirect;
}

add_filter( 'yikes-mailchimp-redirect-timer', 'alter_mailchimp_redirection_timer', 10 );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in /public/partials/shortcodes/process/process_form_shortcode_ajax.php

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-filter-before-submission

Description

Intercept all form data before it gets sent over to Mailchimp. This filter fires after a successful signup and before data is transmitted 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

The following is an example of how to hook in and capture the opt-in form data:

add_filter( 'yikes-mailchimp-filter-before-submission' , 'your_function_name' );

If you want to target a specific form you can append the form ID to the end of the filter name. The following would only effect form with ID 2.

add_filter( 'yikes-mailchimp-filter-before-submission-2' , 'your_function_name' );

Parameters

  • $user_data | Array

A full array of form data, including merge variable and interest group data which will be submitted to Mailchimp.

Examples

This example will increase the time from 1.5s to 5s before redirecting the user after the form has been submitted successfully.

function populate_FNAME_field( $user_data ) {
    if( is_user_logged_in() ) {
        if( isset( $user_data['FNAME'] ) ) {
        get_currentuserinfo();
        $user_data['FNAME'] = $current_user->user_firstname;
        }
    }
return $user_data;
}

add_filter( 'yikes-mailchimp-before-submission' , 'populate_FNAME_field' );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in /public/partials/shortcodes/process/ process_form_shortcode.php and /public/partials/shortcodes/process/process_form_shortcode_ajax.php

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-user-role-access

Description

This filter is allows you to alter who can access Easy Form for Mailchimp by Yikes Inc., by capability. By default only admins can access Easy Forms menu items in the dashboard.

Usage

The following is an example of how to alter the capabilities of who can access the Easy Form for Mailchimp menu items and it’s functionality.

apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' );

Parameters

  • $capability | String | Default: manage_options

The default capability that is allowed to access Easy Forms for Mailchimp, it’s add-ons, menu items and it’s functionality. (defaults to ‘manage_options’ (admin users)).

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_filter( '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

This filter is located in numerous locations throughout the plugin.

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-international-phone-pattern

Description

This filter allows you to alter the regex pattern for acceptable international phone number formats.

Usage

The following is an example of how to alter the capabilities of who can access the Easy Form for Mailchimp menu items and it’s functionality.

apply_filters( 'yikes-mailchimp-international-phone-pattern' , '[0-9]' );

Parameters

  • $regex_pattern | String | Default: [0-9]

The default regex pattern used to validate international phone numbers.

Examples

This example alters the default regex pattern for an international phone number inside of the ‘Phone Number’ input field on opt-in forms.

function alter_yikes_easy_mailchimp_international_phone_regex_pattern( $regex_pattern ) {
    $regex_pattern = '/^\+(?:[0-9] ?){6,14}[0-9]$/'; // alter the default international phone number format
    return $regex_pattern;
}

add_filter( yikes-mailchimp-international-phone-pattern' , 'alter_yikes_easy_mailchimp_international_phone_regex_pattern' );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in process_form_shortcode.php.

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.


yikes-mailchimp-us-phone-pattern

Description

This filter allows you to alter the regex pattern for acceptable United States phone number formats.

Usage

The following is an example of how to alter the capabilities of who can access the Easy Form for Mailchimp menu items and it’s functionality.

apply_filters( 'yikes-mailchimp-us-phone-pattern' , '^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$' );

Parameters

  • $regex_pattern | String | Default: ^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$

The default regex pattern used to validate international phone numbers.

Examples

This example alters the default regex pattern for an United States based phone numbers, inside of the ‘Phone Number’ input field on opt-in forms.

function alter_yikes_easy_mailchimp_us_based_phone_regex_pattern( $regex_pattern ) {
    $regex_pattern = '/^\+(?:[0-9] ?){6,14}[0-9]$/'; // alter the default US phone number format
    return $regex_pattern;
}

add_filter( yikes-mailchimp-us-phone-pattern' , 'alter_yikes_easy_mailchimp_us_based_phone_regex_pattern' );

Placement

This code should be placed in the functions.php file of your active theme.

Source

This filter is located in process_form_shortcode.php.

Since

This filter has been available since version 6.0 of YIKES Easy Forms for Mailchimp.