I need to make the default author for all new posts be already selected but leave existing posts unmodified.
So since the default post status is "draft" i thought to only do this if the post is a draft like so:
add_filter( 'wp_insert_post_data' , 'update_author', '99', 2 );
function update_author($data , $postarr) {
if ($postarr['post_status'] == 'draft') {
$data['post_author'] = 45;
}
return $data;
}
But then it never runs, so i tried the other way around. Do it when it isn't "published" but then it runs for all new and existing posts...
add_filter( 'wp_insert_post_data' , 'update_author', '99', 2 );
function update_author($data , $postarr) {
if ($postarr['post_status'] != 'published') {
$data['post_author'] = 45;
}
return $data;
}
What am i missing here?