Home › Forums › General Issues › Gallery Upload on Front end form
I have a gallery field set up on a front end form, it allows members to login and submit photos. This all works fine.
The issue I have is that they can select and choose from the media gallery, although this is set to ‘Uploaded to post’ under the library setting.
The user is a subscriber, so no admin access.
When editing the post from the front end they are limited to the photos they have uploaded only. It is only on the submission page where they can access the whole media library.
What is causing this and how do I resolve? Is this a bug?
Having this issue on Chrome and Firefox.
In console get this error when clicking add to gallery…
TypeError: wp.media is undefined
I’ve restricted my users with a custom role, granting the ability to manage_photos (their own ones) or manage_others_photos:
add_filter( 'ajax_query_attachments_args', 'show_only_current_user_attachments', 10 );
function show_only_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts') && !current_user_can('manage_others_photos') ) {
$query['author'] = $user_id;
$query['post_parent'] = 0;
} elseif ($user_id && !current_user_can('activate_plugins')) {
$query['post_parent'] = 0;
}
return $query;
}
I also didn’t want to display images that were already attached to other posts, so I’ve filtered those out too in the version above.
If you want a basic version without my additions:
add_filter( 'ajax_query_attachments_args', 'show_only_current_user_attachments', 10 );
function show_only_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts') ) {
$query['author'] = $user_id;
}
return $query;
}
Hello, please how to display active events first then the expired events , i need code!
am using ACF 5.7.10
Screenshot :
https://imagehost.imageupload.net/2020/04/23/FireShot-Capture-024—Evenements—mesloisirs—www.creativejobgroup.com.jpg
please please help me , am beginner on ACF
The topic ‘Gallery Upload on Front end form’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.