Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Force all posts to be assigned to a specific author on save
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
You can’t perform that action at this time.