I have many 'create' and 'edit' forms on the site set to "Use the WordPress Media Library manager for image, video, audio, or file fields" and would like the user to be able to delete images, files etc from the media library that they have uploaded and are attached to that post.
When the user clicks the 'upload or select image' or 'replace image' button in the form the media library pops up. I have a great little snippet in functions.php that allows users to only see the images and files they have uploaded:
To try and keep the media library tidy I would like to add/display the delete option that is available in the media library via admin. See screenshots.
That looks like a permissions issue. On my local test site, when logged in as an Administrator and using a front-end form in this way, I do see the delete link in the Media Uploader.
What is the role of your users?
Are you using Access? Are Media managed by Access? Does that role have permission to delete media?
Oh that's interesting... I have NEVER seen the delete link logged in as any role...
On the site we have the following WordPress user roles in play:
Administrator x 1 (me)
Editor x 1
Author x unlimited (all other account holders on the site)
I don't use Access. On this site the permissions for 8 different member types (all WordPress Authors), subscriptions and numerous 'status' settings is quite complex. I am using Views to manage it all.
Do you think there is a problem and that I SHOULD be able to see the delete option?
- the delete link *is* offered when launching the Media Uploader from the Add Media button on a rich text field (e.g. post content)
- the delete link is *not* offered when launching the Media Uploader from an image field (e.g. Feature image field)
So it looks like it is possible in principle, but it depends upon how the Media Uploader is instantiated.
I'll need the developers to look at this and check whether the settings related to an image field can be modified to work in the same way as the Add Media button.
I'm escalating this, and will report back when I hear from them.
They have, and said they can see when the Media Uploader was introduced in forms a decision was made not to include deleting media, but they are not sure why. They have said that if it is possible to add, they should, but I don't have a timetable for that.
If there is a material update from them I'll let you know.