Home Forums Front-end Issues ACF Form with Gallery Uploader


ACF Form with Gallery Uploader

  • I am using ACF form to allow users to upload photo sets to the site under their profile. I have the gallery field set to only show images in the Media Library that are ‘Uploaded to Post’. Though it’s not showing all images in the Media Library, it seems to be showing all images that were uploaded using that form.

    How can I restrict the images to only ones the current logged in user has uploaded?

  • This is based on information provided here, and part of it is just guessing so let me know how it works out.

    add_filter('ajax_query_attachments_args', 'restrict_images_to_user');
    function restrict_images_to_user($query) {
      if (isset($_POST['query']['_acfuploader']) &&
                                              // use your field key here
          isset($_POST['query']['_acfuploader'] == 'field_XXXXXXX') {
        $author = get_current_user_id();
        $query['author'] = $author;
      return $query;
  • I added something similar to this that I found on Stack Overflow but it didn’t seem to work for me (that I could tell). I ended up using a plugin called WP Users Media that did work. I guess this can be considered solved!

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

The topic ‘ACF Form with Gallery Uploader’ is closed to new replies.