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' );