Skip to content

Instantly share code, notes, and snippets.

@tnorthcutt
Created March 13, 2013 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnorthcutt/5155412 to your computer and use it in GitHub Desktop.
Save tnorthcutt/5155412 to your computer and use it in GitHub Desktop.
Force all posts to be assigned to a specific author on save
<?php
add_action( 'save_post', 'ba_force_post_author' );
function ba_force_post_author( $post_id ) {
//verify post is not a revision
if ( !wp_is_post_revision( $post_id ) ) {
$mypost = array();
$my_post['post_author'] = 2, //The user ID number of the author.
$my_post['ID'] = $post_id;
wp_update_post( $my_post );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment