Support

Account

Home Forums Front-end Issues File filed skip media library

Solved

File filed skip media library

  • Hello.

    I’ve built a front end form using Advanced Forms and have a few upload files present.

    I’d like to make all form-submitted media not appear in the media library. Only accessible via file url.

    Is this possible? Thank you very much!

  • To exclude files from the media library display you must create a pre_get_posts() filter the removes them from the list.

    I don’t remember all of the details of doing this,, but it will require having some way to determine that the files were uploaded through the specific form. Possibly by creating a custom field for files that is set.

    There are many examples of doing this, for example this one only shows files uploaded by the current user https://wordpress.stackexchange.com/questions/76771/how-can-i-hide-media-library-images-from-general-users

  • Thank you very much John. This pointed me in the right direction.

    For anyone wondering, I ended up adding a meta field to the newly created attachment from the upload using update_post_meta after form submission.
    And then pre-filtered the posts query on the upload.php and admin-ajax.php (both media library access points) for attachments without the meta field using pre_get_posts().

    Thank you! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.