1. Go to this page and download the library: Download sebkay/wp-queued-jobs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sebkay / wp-queued-jobs example snippets
use WpQueuedJobs\Jobs\Job;
class BackgroundJob extends Job
{
public function handle()
{
// Handle the job
// Use $this->data to access what was passed with the job when it was added to the queue
}
}
wpj()
->addJob(BackgroundJob::class, 'Data for the background job.')
->dispatch();
add_action('template_redirect', function () {
if (!is_page_template('register-success.php')) {
return;
}
wpj()
->addJob(SendWelcomeEmailJob::class, wp_get_current_user())
->dispatch();
}, 10, 0);