Support

Account

Home Forums ACF PRO ACF Form Gallery Field

Unread

ACF Form Gallery Field

  • Hi there – I am using ACF form to display user profile details. I have a gallery field, which I have managed to restrict media upload library to the user. All is fine with the uploads however, when the caption or alt tags are changed the edits are not saved. Any idea what I can do to allow this? The code used is below.

    And a minor issue the X dashicon is not showing up on the Image to indicate remove. Is there a way to enable this?
    Many thanks
    Charlie

    
    /**
     * Only Show own images in add gallery 
     */
    
    //https://support.advancedcustomfields.com/forums/topic/gallery-field-hide-media-library/
    function restrict_media_library_to_current_user( $wp_query_obj ) {
    
    	if ( ! current_user_can( 'level_5' ) ) {
    
    		global $current_user, $pagenow;
    
    		if (  ! is_a( $current_user, 'WP_User' ) || 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' ) {
    			return;
    		}
    
    		$wp_query_obj->set( 'author', $current_user->ID );
    
    		return;
    	}
    }
    
    add_action( 'pre_get_posts', 'restrict_media_library_to_current_user' );
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.