wpsharks / s2member

s2Member® Framework (membership management for WordPress®).
64 stars 36 forks source link

S2member not sending EOT to Mailchimp #1155

Closed jhall3rd closed 5 years ago

jhall3rd commented 5 years ago

EXPLANATION OF THE ISSUE

STEPS TO REPRODUCE THE ISSUE

With s2-hacks.php modified to include the following:

add_filter('ws_plugin__s2member_mailchimp_merge_array', function ($custom_fields, $vars) { $args = &$vars['args']; // stdClass object.

/*$user_account_eot = s2member_eot();
$eot_date = '';

if ( ! empty( $user_account_eot['time'] ) ) {
    $eot_date = date( 'm/d/Y', $user_account_eot['time'] );
}*/

$eot_date = get_user_meta( get_current_user_id(), 'wp_s2member_auto_eot_time', true );

$custom_fields = array_merge($custom_fields, array(
    //'ADDRESS'   => 'N/A',
    //'PHONE'   => 'N/A',
    'ROLE'  => $args->role,
    'REGDATE' => date( 'Y-m-d', time() ),
    'EOT' => $eot_date

    // A Custom Registration/Profile Field in s2Member can be obtained like this.
    // Note that `my_custom_field_id` should be replaced with the Unique ID that you configured for a field in s2Member.
    // 'MY_CUSTOM_FIELD' => get_user_field('my_custom_field_id', $args->user_id),
));

return $custom_fields;

// Note that custom fields (aka: merge tags) will NOT work unless & until they are created by
// a site owner working inside their MailChimp account. They must first add the custom fields
// so they can be filled by the s2Member filter seen here.

// See: <http://kb.mailchimp.com/merge-tags/using/getting-started-with-merge-tags>

BEHAVIOR THAT I EXPECTED

The EOT should be added to the subscriber profile in Mailchimp. It is not.

BEHAVIOR THAT I OBSERVED

Here's what the log file shows was sent:

[MERGE1] => james [MERGE2] => hall [OPTIN_IP] => 68.3.75.138 [OPTIN_TIME] => 2018-12-19 18:15:03 [ROLE] => s2member_level1 [REGDATE] => 2018-12-19 [EOT] =>