Formidable: Broadcast entries hourly

This snippet for the Broadcast Formidable add-on will broadcast a form’s entries to other sites every hour.

Modify the parts in bold to fit your setup.

/**
 @brief		Schedule an hourly event that broadcast the entries.
 @since		2020-08-26 20:05:58
**/
$key = 'broadcast_formidable_entries';
if ( ! wp_next_scheduled( $key ) )
{
 ThreeWP_Broadcast()->debug( 'Scheduling entry broadcast event.' );
 wp_schedule_event( time(), 'hourly', $key );
}

/**
 @brief	Broadcast a specific form from a source blog to one or more sites.
 @since	2020-08-26 20:06:30
**/
function callback_broadcast_formidable_entries()
{
 ThreeWP_Broadcast()->debug( 'Broadcasting formidable entries.' );
 switch_to_blog( 1 );	// CONFIG - The source form is found on this site.
 $bcf = \threewp_broadcast\premium_pack\formidable\Formidable::instance();
 $bcf->broadcast_entries( [
  'blogs' => [ 3, 4, 5, ],		// CONFIG - Broadcast to these sites
  'form_id' => 2,				// CONFIG - Broadcast the entries of this form
 ] );
 restore_current_blog();
 ThreeWP_Broadcast()->debug( 'Finished broadcasting formidable entries.' );
}
add_action( $key, 'callback_' . $key );