Support

Account

Home Forums ACF PRO disable media library on front end form

Solved

disable media library on front end form

  • When I’m using acf_form v5, so users can post on the front end, when they upload an image how can i hide the media library so front end users can upload only.

  • Hi @m401

    Please set the image setting for library from ‘all’ to ‘Uploaded to post’

  • Hello,
    I set the ‘Uploaded to post’ for libraries and user data edit form shows all the added media…
    Why is this happening?

  • This says “Solved” but it is not solved. When “Uploaded to post” is selected it still shows all the images uploaded.

    * The user is set to “Author” otherwise image uploading is disabled.

  • It still shows all the uploaded images 🙁

  • I’m having this issue as well. I have my field set to only show media uploaded to the post, but on the frontend it’s showing all media items. This, for me, only happens when I’m making a new post on the frontend – always in the admin and when editing a post on the frontend it works as expected.

    Knowing that it works when editing, I’ve been playing around with the attributes sent to acf_form, specifically, post_id. When I set it to 'new' or 'new_post' like the guides say, it doesn’t work – however, when I set it to false for new posts it seems to show the library correctly! This, however, then makes ACF send the post ID from the page displaying the form to acf/load_value when it should be false or blank to indicate it’s a new post. It also makes it impossible to save the new posts..so yeah.

    Anyone figure out what going on here?

  • This seems to finally have been fixed in ACF Pro Version 5.2.0, for the most part. Send a never-valid ID as the post_id for new posts (like -5) and then check for the when you save the post. You’ll need to manually save the post, or add to the acf/pre_save_post filter as described here: http://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/

    It doesn’t work when sending a string as the post_id still using acf_form, but when editing you’re sending an int so it seems to work.

  • Hi @dacrosby Thanks for your suggestion. Is any one else aware of another method? This way seems like a bit of a hack.

  • hi @ch1n3s3b0y ,

    has this problem been resolved already?

    I set the image setting to “Uploaded to post” but that didnt work.

    At the moment I worked around it by using the “basic” uploader ( which has no media libary ),

    'uploader' => 'basic'

    Thanks

  • I found a bit cleaner solution that doesn’t require the basic uploader – use the nice uploader and just stop the Media Library itself from loading.

    
    // Conditionally don't load the Media Library tab/ content
    function remove_medialibrary_tab($strings) {
    	if ( !user_is_admin() ) {
    		unset($strings["mediaLibraryTitle"]);
    		return $strings;
    	} else {
    		return $strings;
    	}
    }
    add_filter('media_view_strings','remove_medialibrary_tab');
    
    // Conditionally don't run the Media Library's initializing AJAX
    function restrict_non_Admins(){
    	if( !user_is_admin() ){
    		exit;
    	}
    }
    add_action('wp_ajax_query-attachments','restrict_non_Admins',1);
    add_action('wp_ajax_nopriv_query-attachments','restrict_non_Admins',1);
    
  • Solved?
    In 2022 I am still experiencing this problem.
    I have a ‘New Post’ form and an ‘Edit Post’ form.

    On the ‘New Post’ form all ‘add image’ buttons pop-up the file uploader (which is exactly what I want) but the ‘Edit Post’ form, all image buttons open the Media Library (which is NOT what I want).

    I have tried all the settings and snippets of code I can find on the web but can not prevent the use of Media Library for image buttons.

    My users (people who will be posting to the website) are not WordPress savvy nor do I want to assume they are so I want simplicity and that means using things they are familiar with; a basic file upload.

    Any help to achieve this would be brilliant.

    Thanks.

    Martin

  • Hi.
    How did you achieve the ‘no media library’ for image fields?

    Where did you add 'uploader' => 'basic'?

    Thanks.

  • You set it in the acf_form arguments e.g.

    acf_form(array('uploader' => 'basic'));

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

The topic ‘disable media library on front end form’ is closed to new replies.