Filter
uncanny-automator
uap_option_get_double_opt_in
Filters the double opt-in setting for Mailchimp integration to customize its behavior.
add_filter( 'uap_option_get_double_opt_in', $callback, 10, 1 );
Description
Filters the double opt-in option for Mailchimp integration. Developers can modify the `$option` array, which contains details like custom value support and options, before it's returned. This hook fires when preparing Mailchimp integration settings.
Usage
add_filter( 'uap_option_get_double_opt_in', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter represents the value of the double opt-in option for Mailchimp integration, which can be modified by filters.
Return Value
The filtered value.
Examples
add_filter( 'uap_option_get_double_opt_in', 'my_custom_double_opt_in_logic', 10, 1 );
/**
* Custom logic to modify the double opt-in settings for a specific integration.
*
* This function checks if the double opt-in setting is currently enabled and
* if so, it might disable it for a particular user role or under specific
* conditions to streamline the signup process for trusted users.
*
* @param array $option The current double opt-in option array.
* @return array The modified double opt-in option array.
*/
function my_custom_double_opt_in_logic( $option ) {
// Check if double opt-in is currently enabled in the settings
if ( isset( $option['enabled'] ) && $option['enabled'] ) {
// Example: If the current user is an administrator, bypass double opt-in.
// This is a hypothetical scenario and might not be applicable to all UAP integrations.
if ( current_user_can( 'administrator' ) ) {
$option['enabled'] = false;
// Optionally, you could also modify the description or other settings here
// $option['description'] = 'Double opt-in is bypassed for administrators.';
}
}
return $option;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/mailchimp/helpers/mailchimp-helpers.php:541
public function get_double_opt_in( $label = null, $option_code = 'MCDOUBLEOPTIN', $args = array() ) {
if ( ! $label ) {
$label = esc_html_x( 'Double opt-in', 'Mailchimp', 'uncanny-automator' );
}
$args = wp_parse_args(
$args,
array(
'uo_include_any' => false,
'uo_any_label' => esc_html_x( 'Any tag', 'Mailchimp', 'uncanny-automator' ),
)
);
$options = array();
$options[] = array(
'value' => 'yes',
'text' => esc_html_x( 'Yes', 'Mailchimp', 'uncanny-automator' ),
);
$options[] = array(
'value' => 'no',
'text' => esc_html_x( 'No', 'Mailchimp', 'uncanny-automator' ),
);
$token = key_exists( 'token', $args ) ? $args['token'] : false;
$is_ajax = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
$end_point = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';
$description = key_exists( 'description', $args ) ? $args['description'] : '';
$options = key_exists( 'options', $args ) ? $args['options'] : $options;
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'description' => $description,
'required' => true,
'supports_tokens' => $token,
'is_ajax' => $is_ajax,
'fill_values_in' => $target_field,
'endpoint' => $end_point,
'custom_value_description' => '',
'supports_custom_value' => false,
'supports_multiple_values' => false,
'options' => $options,
'hide_actions' => isset( $args['hide_actions'] ) ? $args['hide_actions'] : false,
);
return apply_filters( 'uap_option_get_double_opt_in', $option );
}