Programatically change post author
It shouldn’t be any problem. Try this: $arg = array( ‘ID’ => $post_id, ‘post_author’ => $user_id, ); wp_update_post( $arg );
It shouldn’t be any problem. Try this: $arg = array( ‘ID’ => $post_id, ‘post_author’ => $user_id, ); wp_update_post( $arg );
You can remove the callback from the save_post hook, update the post and then re-add the call back to the hook. The Codex gives an example. add_action(‘save_post’, ‘wpse51363_save_post’); function wpse51363_save_post($post_id) { //Check it’s not an auto save routine if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) return; //Perform permission checks! For example: if ( !current_user_can(‘edit_post’, $post_id) ) … Read more
Since WordPress version 3.7. – IIRC – the save_post hook – more information about the hook and its usage at Code Reference: save_post and Codex: save_post – has a third parameter $update which can be used to determine just that. @param int $post_ID Post ID. @param WP_Post $post Post object. @param … Read more