get_edit_post_link() not working on wp-cron
Question
I have a “real” cron job that executes wp-cron.php every now or then. I collect the link in to a variable by $link = get_edit_post_link(ID);
It works flawlessly if I am logged in and execute cron manually with wp-cron.php but when it is executed by schedule it wont collect the link and leaves it empty.
Striped down version of code:
foreach($published_posts as $post_to_private){
$user_data = get_userdata( $post_to_private->post_author);
$email = $user_data->user_email;
$link = get_edit_post_link( $post_to_private->ID);
$email = WP_Mail::init()
->to($email)
"X-Mailer: PHP/". phpversion(),
"Content-type: text/html; charset=utf-8",
])
->subject('test')
->template(plugin_dir_path( __DIR__ ) .'email-templates/expired-transit-email.php', [
'link' => $link,
]);
//for testing of email
return $email->send();
Any ideas?
0
php, plugins, wp-cron
4 years
2020-02-16T08:39:00-05:00
2020-02-16T08:39:00-05:00 0 Answers
72 views
0
Leave an answer