Home › Forums › Backend Issues (wp-admin) › Add category to file and filter media library › Reply To: Add category to file and filter media library
The media library is only shown for those that can have access to it. If the user is a subscriber or some other type of user that is not allowed to edit media then the simple upload field will be used. Try testing this by logging in as the user type you plan on allowing this form for.
Also when creating a field you can specify to only allow files that are attached to the post.
As far as adding a specific category when the file is uploaded. I’m not entirely sure you can do that. You might try creating either an acf/pre_save_post http://www.advancedcustomfields.com/resources/acf-pre_save_post/ or an acf/save_post http://www.advancedcustomfields.com/resources/acfsave_post/ action. I’m not sure which one would be better for this. In this action you’d need to get the attachment ID value from the ACF field and then add the category to the attachment post using wp_set_object_terms() https://codex.wordpress.org/Function_Reference/wp_set_post_terms
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.