Home / Admin / Trigger a Scheduled Export via a WordPress Action
Duplicate Snippet

Embed Snippet on Your Site

Trigger a Scheduled Export via a WordPress Action

<10
Code Preview
php
<?php
function custom_trigger_scheduled_export_url() {
    $secret_key = ( isset( $_GET['secret_key'] ) ? sanitize_text_field( $_GET['secret_key'] ) : false );
    if( empty( $secret_key ) ) {
        return;
    }
    if( $secret_key == 'SECRET_KEY_PASSED_VIA_CRON' ) {
        // This is the Post ID of the Scheduled Export you wish to trigger
        $scheduled_export = 100;
        $time = current_time( 'timestamp', 1 );
        $hook = 'woo_ce_auto_export_schedule_' . $scheduled_export;
        $args = array(
            'id' => $scheduled_export
        );
        wp_schedule_single_event( $time, $hook, $args );
        echo 1;
        exit(); 
    }
}
add_action( 'init', 'custom_trigger_scheduled_export_url', 11 ); 

Comments

Add a Comment