I have an wordpress app and in witch I want to set a cron that will execute my function once a day, but testing this crone I get a problem that I can’t acces function when crone is runging.
add_action('init', 'schedule_custom_event');
function schedule_custom_event() {
if (!wp_next_scheduled('my_custom_event')) {
wp_schedule_event(time(), 'thirty_seconds', 'my_custom_event');
}
}
// Hook the event to your function
add_action('my_custom_event', 'my_map_events_function');
function my_map_events_function() {
// Your function logic here
error_log('There I console log a text once in 30 seconds');
}
This is my code that I added in function.php and when cron is runing I can’t see the message from my_map_events_function function. I need every for my test to set every 30 seconds to write message from my_map_events_function().