Update post outside WP causes revision with no author
-
Hi guys I thought I’d post here before reporting this as an issue.
I use wp_insert_post in a script that runs via cron and therefore not as a logged in user. I manually set post_author to an existing user. When I insert a new post this works as expected (the author is set), but when I use this method to update an existing post a revision is created with the author set to 0 (blank).
I traced this down to the _wp_post_revision_fields function in revision.php which strips the post_author field from the post object before the revision is saved via wp_insert_post which in turn tries to get the currently logged in user.. Which is non-existant..
Right now the non-obtrusive solution would be to use the _wp_put_post_revision action to update the revision with the correct author.
- The topic ‘Update post outside WP causes revision with no author’ is closed to new replies.