Term and post save hooks cause object creation to fail during cron jobs
-
Hi,
I have a bulk content synchronisation job running via WP Cron that fails when creating new terms and posts that are checked for i18n support.
The term and post hooks registered by your plugin in
PLL_Admin_Filters_Term::save_term()
andPLL_Admin_Filters_Post::save_post()
are doing acurrent_user_can()
check which fails and throws awp_die()
when executing a cron job.The fix for this is to check for the
DOING_CRON
constant ibefore validating user permissions:
if (!defined( 'DOING_CRON' ) || !DOING_CRON) {
if (($update && !current_user_can($post_type_object->cap->edit_post, $post_id)) || (!$update && !current_user_can($post_type_object->cap->create_posts)))
wp_die( __( 'Cheatin’ uh?' ) );
}
- The topic ‘Term and post save hooks cause object creation to fail during cron jobs’ is closed to new replies.