Change WordPress user roles and capabilities Forums How to or FAQ Edit Page – but a specific page only Reply To: Edit Page – but a specific page only

#5969
Vladimir
Keymaster

But I don’t want this role to be able to delete any pages, not even the pages I gave them access to edit.

Just remember that is default WordPress permissions – in order to delete item from Media Library user should can delete the page to which this image was attached.

There is workaround for your situation – force WordPress to use unique user capabilities for all post types including ‘attachment’ one.
Make fresh database backup – for the case if you will wish to rollback changes.
Go to Settings->User Role Editor->Additional Modules. Turn ON “Force custom post types to use their own capabilities” option under “Content editing restrictions” section. Go through your roles and check if they need new created capabilities, like for ‘Attachments’ post type.

You can grant to a role ‘delete_attachments’ instead of ‘delete_pages’, etc. in this case.