Skip to content

Commit

Permalink
see madaritech#7: add a filter to allow 3rd parties to manipulate the…
Browse files Browse the repository at this point in the history
… merge variables before the request is sent to MailChimp
  • Loading branch information
ziodave committed Jul 19, 2017
1 parent 7419906 commit 65ff18b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion admin/class-sincro-mailchimp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,24 @@ public function subscribe_user( $user_email, $smc ) {

foreach ( $smc as $list_id => $interests ) {
$args['interests'] = $interests;
$add_status = $this->add_list_member( $list_id, $args );

/**
* Call the `sm_merge_fields` filter to allow 3rd parties to preprocess the `merge_fields` before the
* request to MailChimp.
*
* @since 1.0.0
*
* @api
*
* @param array array() An empty array of merge fields.
* @param string $user_email The user's e-mail address.
* @param string $list_id The MailChimp list's id.
* @param array $interests An array of interests' ids.
* @param array $smc The Sincro_Mailchimp configuration's array.
*/
$args['merge_fields'] = apply_filters( 'sm_merge_fields', array(), $user_email, $list_id, $interests, $smc );

$add_status = $this->add_list_member( $list_id, $args );

if ( Sincro_MailChimp_Log_Service::is_enabled() ) {
$this->log->trace( "Call to `add_list_member` returned [ " . var_export( $add_status, true ) . " ]" );
Expand Down
2 changes: 1 addition & 1 deletion includes/class-sincro-mailchimp-log-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function trace( $message ) {
$this->log( 'TRACE', $message );

}

/**
* Internal log function.
*
Expand Down

0 comments on commit 65ff18b

Please sign in to comment.