-
Notifications
You must be signed in to change notification settings - Fork 1
Add user synchronization #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if ( $current_status ) { | ||
switch ( $current_status ) { | ||
// If user is already subscribed, unsubscribed or transactional, don't change the status. | ||
case 'subscribed': | ||
case 'unsubscribed': | ||
case 'transactional': | ||
$subscribe_status = $current_status; | ||
break; | ||
|
||
// If user is cleaned, set the status as pending. | ||
case 'cleaned': | ||
$subscribe_status = 'pending'; | ||
break; | ||
|
||
// If user is archived, pending or anything else, set the status as per the subscribe status in settings. | ||
case 'archived': | ||
case 'pending': | ||
default: | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For existing Mailchimp contacts, we mostly don't update the status according to the settings on the WP side. However, for statuses like cleaned
, archived
, and pending
, we do consider updating them based on the user sync settings.
Please let me know if you think we should handle this differently. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code here looks great! Only question I have is in regards to the inclusion of Action Scheduler. Would it make sense to only include that if either a sync is manually triggered or the option to keep users in sync is set? That way we aren't loading Action Scheduler unless we need it? Not sure how hard that would be to accomplish
Co-authored-by: Darin Kotter <[email protected]>
… sync is enabled.
I tried setting up a custom option when we start the manual user sync and load the Action Scheduler only if that option is set (it gets cleared once the sync is complete) or if auto sync is enabled. I'm not sure if this is the best way to do it, but it seems to work fine. You can check the change at: 809b7a7 Thanks! |
QA Update ✅I have verified this PR in the I tested the following on this branch:
Synchronize.All.Users.1.movSync.existing.contacts.only.2.movTesting Environment
Steps to Test- As mentioned in the PR description.
|
<?php esc_html_e( 'Sync as non-subscribed', 'mailchimp' ); ?> | ||
</label> | ||
<p class="description_small"> | ||
<?php esc_html_e( 'This status indicates you haven\'t gotten permission to market to these users. However, you can use Mailchimp to send ', 'mailchimp' ); ?><a href="https://mailchimp.com/help/about-non-subscribed-contacts/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'non-subscribed contacts', 'mailchimp' ); ?></a> <?php esc_html_e( 'transactional emails and postcards and target them with ads.', 'mailchimp' ); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps simpler to change the second sentence to:
However, you can use Mailchimp to message non-subscribed contacts.
?> | ||
<input type="checkbox" name="<?php echo esc_attr( $this->option_name . '[existing_contacts_only]' ); ?>" value="1" <?php checked( $existing_contacts_only, 1, true ); ?> /> | ||
<p class="description"> | ||
<?php esc_html_e( 'Only WordPress users who are already in your Mailchimp audience will sync. You won\'t be able to send your other users postcards or target them with ads.', 'mailchimp' ); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably simpler to just remove the second sentence here
<div> | ||
<label for="subscriber_status_transactional" class="subscribe_status_label"> | ||
<input type="radio" id="subscriber_status_transactional" name="<?php echo esc_attr( $this->option_name . '[subscriber_status]' ); ?>" value="transactional" <?php checked( $settings, 'transactional' ); ?> /> | ||
<?php esc_html_e( 'Sync as non-subscribed', 'mailchimp' ); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's capitalize here to:
Sync as Non-Subscribed
@vikrampm1 can you please open a follow-up issue where we display in the WP Users table list view some sort of notation noting users that are synced to Mailchimp? Perhaps a column & icon similar to what we do in Distributor and then have that icon link to the specific audience? |
Description of the Change
This PR adds functionality to sync WordPress users to Mailchimp. It provides options to select user roles to sync and to choose the subscription status for users in the user sync settings.
The feature allows manual syncing of all users at once using background processing and also listens for new user registrations and updates to existing users. Currently, the sync is one-way (WordPress → Mailchimp). The feature also includes a UI to view users that failed to sync, along with the associated error messages. I have created #157, to handle update subscription status from user profile separately.
Quick Demo:
Screen.Recording.2025-05-15.at.3.46.56.PM.mov
Closes #155
How to test the Change
Prerequisites:
Manual Sync:
Auto Sync:
Changelog Entry
Credits
Props @dkotter @jeffpaul @iamdharmesh
Checklist: