Skip to content

How To Add Tasks

modemlooper edited this page Aug 5, 2017 · 11 revisions

// Function to add tasks

taskbot_add_items( array(
    'task' => 'task_id', // this is the id of the task. saved to each batch, used during recess hook
    'items' => array(), // the items to be processed. This would be something like array of user ids
    'data' => array(), // extra data to use during each item process.
) );

// Hook your item process to a dynamic action hook.

function wp38282_process_item( $task_data ) {

}
add_action( 'taskbot_run_{task_id}', 'wp38282_process_item' ); 

{task_id} should be the task from taskbot_add_items function args. TaskBot will hit this action for each item. You can use code you want process the item.

Clone this wiki locally