Filter
uncanny-automator
automator_mailchimp_webhook_endpoint
Filters the Mailchimp webhook endpoint URL used for integrations.
add_filter( 'automator_mailchimp_webhook_endpoint', $callback, 10, 1 );
Description
Filters the Mailchimp webhook endpoint URL. Developers can modify this to change the default '/mailchimp' path where Mailchimp webhooks are received, allowing for custom routing or integration points.
Usage
add_filter( 'automator_mailchimp_webhook_endpoint', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter defines the base endpoint URL path for Mailchimp webhooks within the automator.
Return Value
The filtered value.
Examples
/**
* Example of filtering the Mailchimp webhook endpoint.
*
* This function demonstrates how to modify the default Mailchimp webhook endpoint.
* In a real-world scenario, you might want to prepend a specific slug
* to the endpoint for better organization or security.
*
* @param string $endpoint The current webhook endpoint.
* @param object $mailchimp_instance The instance of the Mailchimp integration class.
* @return string The modified webhook endpoint.
*/
add_filter( 'automator_mailchimp_webhook_endpoint', function( $endpoint, $mailchimp_instance ) {
// Ensure the Mailchimp instance is valid before proceeding.
if ( ! is_a( $mailchimp_instance, 'Automator_Mailchimp_Integration' ) ) {
return $endpoint;
}
// Prepend a custom slug to the default Mailchimp webhook endpoint.
// For example, changing '/mailchimp' to '/my-automation/mailchimp'.
$custom_slug = 'my-automation';
$modified_endpoint = '/' . trim( $custom_slug, '/' ) . $endpoint;
return $modified_endpoint;
}, 10, 2 );
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:95
public function __construct() {
add_action( 'init', array( $this, 'validate_oauth_tokens' ), AUTOMATOR_APP_INTEGRATIONS_PRIORITY, 3 );
add_action( 'wp_ajax_select_mcgroupslist_from_mclist', array( $this, 'select_mcgroupslist_from_mclist' ) );
add_action( 'wp_ajax_select_mctagslist_from_mclist', array( $this, 'select_mctagslist_from_mclist' ) );
add_action( 'wp_ajax_select_segments_from_list', array( $this, 'select_segments_from_list' ) );
add_action( 'wp_ajax_get_mailchimp_audience_fields', array( $this, 'get_mailchimp_audience_fields' ) );
add_action( 'wp_ajax_uo_mailchimp_disconnect', array( $this, 'uo_mailchimp_disconnect' ) );
add_action( 'wp_ajax_mailchimp-regenerate-webhook-key', array( $this, 'regenerate_webhook_key_ajax' ) );
// Load webhook method once webhook option is enabled.
if ( $this->is_webhook_enabled() ) {
$this->webhook_endpoint = apply_filters( 'automator_mailchimp_webhook_endpoint', '/mailchimp', $this );
$this->define_webhook_listener();
}
// Load the settings page.
require_once __DIR__ . '/../settings/settings-mailchimp.php';
new Mailchimp_Settings( $this );
}