Skip Navigation

[Escalated to 2nd Tier] allow users to delete their own media attachements via cred form

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 7 replies, has 2 voices.

Last updated by Rita 4 months, 2 weeks ago.

Assisted by: Nigel.

Author
Posts
#2707333
upload or select image button in cred form.png
replace image button in cred form.png
delete option in media library via admin.png
cred form add media popup.png

Hi there

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:

add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments' );
function show_current_user_attachments( $query ) {
    $user_id = get_current_user_id();
    if ( $user_id ) {
        $query['author'] = $user_id;
    }
    return $query;
}

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.

Hoping this is possible!

Rita

#2707363

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Rita

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?

#2707364

Hi Nigel

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?

R

#2707430

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, re-testing, it appears that

- 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.

#2707467

That would be excellent Nigel. Standing by.

#2711064

Hi Nigel
How are we going with this?
Have the developers had a chance to look at this yet?
Rita

#2711230

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

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.

#2711250

Ok. Thanks Nigel.