[wp-hackers] Allow users to upload their own images - hook to use?

Otto otto at ottodestruct.com
Wed Sep 11 23:06:55 UTC 2013


Seems like you're overthinking it here.

When you upload a file into WordPress using the normal methods, then
the file is saved, and a new Post is created with a post-type of
"attachment". That attachment post is a full fledged post. It has its
own post_author and everything.

Getting a list of all the media files a user uploaded can be done with
the normal queries. Just query for post_author = user-id and post_type
= attachment. Simple.

Now, attachment posts can be connected to a normal Post post, and this
is done by setting the post_parent of the attachment post equal to the
post ID of the Post post. But, you don't really need that just to
associate uploads to users, because uploaded files are *already*
associated to users, in that they're the post_author of the attachment
post.

-Otto



On Wed, Sep 11, 2013 at 6:01 PM, BenderisGreat
<greglancaster71 at gmail.com> wrote:
> Wait this could be the answer to everything I need done.  You said I can
> attach it to a post, so each users uploads would be associated to their
> specific post.  If I am doing that is it also possible to associate the data
> I am saving with my form to that post as well?  How would that be done?
> custom fields or something?
>
>
>
> --
> View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Allow-users-to-upload-their-own-images-hook-to-use-tp42264p42270.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list