I am working on a custom theme, in which I need to programmatically inserts posts and attachments. One requirement is those posts belong to users that are not the user who is logged in and running the action.
To give you an example, an admin user logs in to WordPress, and runs this custom action. The custom action will create suggested posts for two other users, user1 and user2.
Now if user1 logs in, he/she will see a suggested post and he can choose to publish it.
Everything is cool and dandy so far, because the function
wp_insert_post allows for programattic insertion of posts. One of the arguments that this function takes is
post_author which can be set to the id of either user1 or user2.
So far, everything is still great.
Now, those post will have attachments (images). My question is, is there a way to add a
post_author to the
wp_insert_attachment? I could not find that in the documentation. I need the attachment to have the same author id as that of the post. Currently it takes the id of the the admin.