Hello,
Same issue for me.
Did you find any solution ?
I still have the same problem, if you know of any solution please let me know.
Thanks greetings.
The issue is related to js handling :
Console error when clicking on the button “Add to the gallery” :
acf-input.min.js?ver=5.12.3:1 Uncaught TypeError: Cannot read properties of undefined (reading 'query')
at n.addFrameStates (acf-input.min.js?ver=5.12.3:1:64429)
at n.initialize (acf-input.min.js?ver=5.12.3:1:63808)
at n.e (acf.min.js?ver=5.12.3:1:2945)
at acf.Model (acf.min.js?ver=5.12.3:1:3079)
at n [as constructor] (acf.min.js?ver=5.12.3:1:6250)
at new n (acf.min.js?ver=5.12.3:1:6250)
at acf.newMediaPopup (acf-input.min.js?ver=5.12.3:1:63252)
at n.onClickAdd (acf-pro-input.min.js?ver=5.12.3:1:10280)
at n.<anonymous> (acf.min.js?ver=5.12.3:1:4423)
at HTMLAnchorElement.i (jquery.min.js?ver=3.6.0:2:88757)
No solution for the moment.
Hello,
I found a solution, the “issue” is coming because this field has to load the WordPress media Library to user SO user role must have capability to upload_files.
Check permissions here : https://ww.wp.xz.cn/support/article/roles-and-capabilities/
In my case, I just changed my custom role caps from subscriber to author :
add_role( 'my_role', 'Role Name', get_role( 'subscriber' )->capabilities );
You have to add some code to prevent users seing media from other users.
You can try something like that :
add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
function show_current_user_attachments( $query = array() ) {
$user_id = get_current_user_id();
if( $user_id ) {
$query['author'] = $user_id;
}
return $query;
}
Ref : https://developer.ww.wp.xz.cn/reference/hooks/ajax_query_attachments_args/
Hope this helps.
-
This reply was modified 3 years, 9 months ago by
Joffrey Nicoloff. Reason: Add code for show only user attachments
Hello,
Thanks for the feedback!
The Gallery Field is a native ACF field, and is not part of the ACF Extended plugin.
As @agent3w pointed out, this field requires users to be logged-in in order to be used (including on the front-end). This is because the field use the WP Media Modal which is tied to user role and capabilities.
You can find multiple posts about this topic on the ACF Support Forum:
I don’t know if ACF planned to fix the issue in the future tho.
Hope it helps!
Have a nice day!
Regards.