Using Gravity Forms ‘gform_polls_cron’ PHP action

The gform_polls_cron Gravity Forms PHP action allows further actions to be performed after the cron job that gathers poll results runs.

Usage

add_action('gform_polls_cron', 'your_function_name');

Parameters

There are no parameters.

More information

See Gravity Forms Docs: gform_polls_cron

Examples

Send an email after the cron job runs

This example sends an email when the polls cron job finishes running.

add_action('gform_polls_cron', 'send_message_after_cron_runs');

function send_message_after_cron_runs() {
    GFCommon::send_email('[email protected]', '[email protected]', '', '', 'Polls Cron Job', 'The polls cron job has run.');
}

Log the cron job completion time

This example logs the completion time of the polls cron job.

add_action('gform_polls_cron', 'log_cron_completion_time');

function log_cron_completion_time() {
    error_log('Polls cron job completed at: ' . date('Y-m-d H:i:s'));
}

Update a custom database table

This example updates a custom database table with the completion time of the polls cron job.

add_action('gform_polls_cron', 'update_custom_table');

function update_custom_table() {
    global $wpdb;
    $table_name = $wpdb->prefix . 'custom_polls_cron';
    $completion_time = date('Y-m-d H:i:s');
    $wpdb->insert($table_name, array('completion_time' => $completion_time));
}

Trigger another function

This example triggers another function after the polls cron job has run.

add_action('gform_polls_cron', 'trigger_custom_function');

function trigger_custom_function() {
    my_custom_function();
}

function my_custom_function() {
    // Your custom code here
}

Run another cron job

This example schedules another cron job to run after the polls cron job has run.

add_action('gform_polls_cron', 'schedule_another_cron_job');

function schedule_another_cron_job() {
    if (!wp_next_scheduled('my_custom_cron_job')) {
        wp_schedule_single_event(time() + 60, 'my_custom_cron_job');
    }
}

add_action('my_custom_cron_job', 'run_my_custom_cron_job');

function run_my_custom_cron_job() {
    // Your custom code here
}