I
I
Ilya Parshakov2016-02-12 16:57:55
PHP
Ilya Parshakov, 2016-02-12 16:57:55

The script scheduled in CRON is not executed, PHP Fatal error, how to fix it?

Hello, please help!
I set up a rule on the hosting server (via a browser from a personal account) for executing a php script.
Script: send email messages to wordpress users from get_users() array.
If you run the script from the page, then everything works, but through CRON it gives an error:
PHP Fatal error: Call to undefined function get_users() in /home/c/cx90140/public_html/mailer.php on line 2
That is, as I understand it , cron and know does not know about any array with users and even more so about wordpress.
Please tell me how to fix?

<?php
$users = get_users();
$total_users = count($users);
shuffle($users);

$mail_list = array_map(function($q){
   return get_the_author_meta('user_email', $q->ID);
}, $users);

for ($i = 0; $i <= $total_users; $i += 1) {
mail($mail_list[i], "Тема", "Сообщение", $mail_list[i+1]);
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2016-02-12
@parschakov

Where is the description of the get_users function?
You must require the file(s) in which the get_users function will be described.
You also need the get_the_author_meta function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question