Support

Account

Home Forums ACF PRO ACF Form Gallery Field

Solved

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' );
  • I don’t think this has anything to do with your code, but it might.

    If this code is removed, are the edits you mention saved when the same user type updates them?

  • Hi thanks for you reply and sorry I should have marked this as solved – Mike sent me a private reply which solved it.
    Cheers

    I am afraid that from our end, we can be of much assistance as this depends on the user’s capability role and not the ACF side as the code is controlled from the WP end but not the ACF side.

    To test that out, you can allow the subscriber user to add an image to the gallery and try uploading from the back-end without using ACF and you will notice that the subscriber user cannot make changes to the alt, title, description, as well as the caption text.
    ..you can make use of the user editor role plugin, to enable the subscriber upload_files, edit_post, as well as edit_published_posts, then amend your code to take care of the subscriber and you would be in a position to change the caption or alt tags.

    That said, please have a look at the following screencast on the same: https://www.loom.com/share/4cb6bc1124c1402284384061e19d4768

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

You must be logged in to reply to this topic.