Support

Account

Home Forums Front-end Issues ACF Form with Gallery Uploader Reply To: ACF Form with Gallery Uploader

  • This is based on information provided here https://support.advancedcustomfields.com/forums/topic/filter-gallery-items/, 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;
    }