I created a metabox into my posts, it's a checkbox that I checked.
Here's the code for saving the data :
add_action('save_post','save_metaboxes');
function save_metaboxes($post_ID){
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
//Don't update on Quick Edit
if (defined('DOING_AJAX') ) {
return $post_id;
}
if(isset($_POST[ 'is_viewpay' ])) {
update_post_meta($post_ID, '_is_viewpay', 'active');
} else {
update_post_meta($post_ID, '_is_viewpay', '');
}
}
The problem is :
It's working when I manually set my post from scheduled to published (click on publish button)
But when the post automatically published, my meta value does not save at all.
I don't know why it's not working..
Thanks for your help !
_is_viewpay
is empty or does not appear in DB table at all?