I have multiple author accounts on one of my WordPress installs. Often I will create a post, and set the author to be a different account. However, when I upload images into that post, their attachment page lists the author as my account. How can I set the author for posts, and have it carry over to the media associated with that post?
Leave a Reply
You must be logged in to post a comment.
Use this in your theme’s
functions.php
:I extended the above solution of @brasofilo to also change the attachment post date to the date of the post parent.
And not only on upload of the attachment, but also when an attachment is edited. You can use the
edit_attachment
filter with the same function for this. However, when you do that, thewp_update_post
function causes an infinite loop and leads to PHP memory errors, I found out the hard way after a lot of searching.A warning for this infinite loop is actually mentioned in the Codex.
A solution is to remove the filters, like so: