Created
December 11, 2020 14:02
-
-
Save verygoodplugins/42198a5f1e3100234f58cb8ca5a375ff to your computer and use it in GitHub Desktop.
Creates a daily cron to run an Import Users operation via WP Fusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This runs every day and imports any new users from the connected CRM who have the specified tag ID ("123" in this example) | |
// If contacts with that tag already have user accounts on the site they will be skipped and no data will be loaded | |
// i.e. this just imports *new* users | |
if ( ! wp_next_scheduled( 'wpf_daily_import' ) ) { | |
wp_schedule_event( time(), 'daily', 'wpf_daily_import' ); | |
} | |
function do_wpf_daily_import() { | |
$args = array( | |
'tag' => 123, // The tag ID or list ID (with HubSpot) to import | |
'role' => 'subscriber', | |
'notify' => false, // Set to true to send a welcome email | |
); | |
wp_fusion()->batch->batch_init( 'import_users', $args ); | |
} | |
add_action( 'wpf_daily_import', 'do_wpf_daily_import' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment