Front End Form Submission

Posted in: Newspaper
Post count: 162

Hello Team,

How can the ‘Form Content’ element be customised?

a) the dropdown ‘shortcodes’ : how to remove that?
b) the ‘Add Media’ doesn’t show for logged-out visitors.
c) For logged-in users, “add media” gives access to the WP Media Library — can this be changed such that the user only sees their own browse-files-folder “choose file to upload” ?

Post count: 21065

Hello @theheritagelab!

Check this guide: https://forum.tagdiv.com/create-frontend-submission-form/
a) You can’t edit or remove that.
b) Normally, you should be logged in to publish a post.
c) Unfortunately, you can’t restrict only that.

Thank you!

Post count: 10

C) Just had the same problem. Here is a quick function to to just that:
/* User should only see media files they uploaded themselves */
function restrict_media_library_to_user_uploads($query) {
if (!is_admin() || defined(‘DOING_AJAX’) && DOING_AJAX) {
$user_id = get_current_user_id();
if (!current_user_can(‘administrator’)) { // Optionally exempt administrators
$query[‘author’] = $user_id;
}
}
return $query;
}
add_filter(‘ajax_query_attachments_args’, ‘restrict_media_library_to_user_uploads’);

Just add this code to your functions.php and that’s it.

Post count: 162

Thank you @sixeleven ! That worked perfect.

Though it seems the user is unable to create a gallery – but at least the main problem is solved. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.