Support

Account

Home Forums ACF PRO Gallery field hide media library Reply To: Gallery field hide media library

  • What type of users will be using this front end form? Have you tried logging into your site as that type of user? Does that type of user have access to the media library? If not then the gallery field isn’t going to work for them and you’ll need to provide them with an alternate to the gallery.

    Assuming that they do have access to the media library you can limit the images that they see to only the ones they uploaded by using a pre_get_posts filter.

    
    add_filter('pre_get_posts', 'limit_gallery_to_user');
    function limit_gallery_to_user($query) {
      if (is_admin() || 
          !isset($query->query_vars['post_type']) ||
          $query->query_vars['post_type'] != 'attachment') {
        return;
      }
      $user_id = get_current_user_id();
      $query->set('author', $user_id);
    }
    

    If they don’t have access to the medial library and the gallery does not work you will probably need to use a repeater field with image fields and then transfer the images to the gallery using an acf/save_post filter.