A Web Development & Designing and programming code. Learn Wordpress tips and hacks From Videos and code in Description. Languages used are C, C++, C#, PHP, Mysql for developing Websites, Computer Network Programs, Android, Data Structure Programs, Object-Oriented Programming and more Google me: 'Sahil Gulati Surat'
Showing posts with label cron job. Show all posts
Showing posts with label cron job. Show all posts
Wednesday, April 1, 2020
Monday, March 30, 2020
Implementing cron job in WordPress
function myplugin_activate()
{
if (!wp_next_scheduled('pt_my_task_hook')) {
//wp_schedule_event(time(), 'hourly', 'pt_my_task_hook');
//wp_schedule_event(time(), 'every_three_minutes', 'pt_my_task_hook');
wp_schedule_event(strtotime('22:00:00'), 'daily', 'pt_my_task_hook');
}
}
register_activation_hook(__FILE__, 'myplugin_activate');
/* Deactivate Hook */
register_deactivation_hook(__FILE__, 'my_deactivation');
function my_deactivation()
{
wp_clear_scheduled_hook('pt_my_task_hook');
}
add_action('pt_my_task_hook2', 'user_email_task_function');
function user_email_task_function()
{
// code to implement
}
{
if (!wp_next_scheduled('pt_my_task_hook')) {
//wp_schedule_event(time(), 'hourly', 'pt_my_task_hook');
//wp_schedule_event(time(), 'every_three_minutes', 'pt_my_task_hook');
wp_schedule_event(strtotime('22:00:00'), 'daily', 'pt_my_task_hook');
}
}
register_activation_hook(__FILE__, 'myplugin_activate');
/* Deactivate Hook */
register_deactivation_hook(__FILE__, 'my_deactivation');
function my_deactivation()
{
wp_clear_scheduled_hook('pt_my_task_hook');
}
add_action('pt_my_task_hook2', 'user_email_task_function');
function user_email_task_function()
{
// code to implement
}
Subscribe to:
Posts (Atom)