Skip to content

Instantly share code, notes, and snippets.

@ideag
Forked from anonymous/tiny-change
Last active December 15, 2015 00:38
Show Gist options
  • Save ideag/5174195 to your computer and use it in GitHub Desktop.
Save ideag/5174195 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: tinyChangeAuthor
Plugin URI: https://gist.github.com/ideag/5174195/
Description: Change post author on save
Author: @IdeaG (tinyStudio)
Version: 0.1
Author URI: http://wp.tribuna.lt
*/
add_action( 'save_post', 'tiny_change_author' );
function tiny_change_author( $post_id ) {
if ( !wp_is_post_revision( $post_id ) ) {
remove_action('save_post', 'tiny_change_author');
wp_update_post(array('ID' => $post_id, 'post_author' => 1));
add_action('save_post', 'tiny_change_author');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment