Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
Created December 11, 2020 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verygoodplugins/42198a5f1e3100234f58cb8ca5a375ff to your computer and use it in GitHub Desktop.
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
<?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