Set default post author to none on new post

On a large multisite install with 200 authors I need the author on new posts to default to none.

I unset the post_author div and moved it to the publish box (where it should be anyway) and wrote a new post_author_meta_box function since there is no way to change the wp_dropdown_users $args. <–track ticket.

Read More

It works and sets the author to none but when a post is edited it goes back to none instead of the previously saved author.

//Replacement for post_author_meta_box 

function better_author_meta_box($post) { ?>  
   <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> <?php

    if ( empty($post->ID) ) : $selected = false; else : $selected = $post->post_author; endif;
    wp_dropdown_users( array(
            'who' => 'authors',
            'name' => 'post_author_override',
            'selected' => $selected,
//also tried: 'selected' => empty($post->ID) ? false : $post->post_author, 
            'include_selected' => true,
            'show_option_none' => 'NONE'
      ) );
  }

//Moves post_author_div to the publish box
add_action( 'post_submitbox_misc_actions', 'move_author_meta' );
function move_author_meta() {
global $post_ID;
$post = get_post( $post_ID );
echo '<div id="author" class="misc-pub-section" style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">Author: ';
better_author_meta_box( $post );
echo '</div>';
}

Related posts

Leave a Reply

1 comment

  1. I figured out a solution so I’m leaving the question up as it might be helpful to someone else.

    if ( 'auto-draft' == $post->post_status ) : 
       $selected = false; 
      else : 
       $selected = $post->post_author; 
    endif;