Site logo

Archived topic

Hide [Upload files] by role at Media Library

3 replies · Started by martin_ym on October 30, 2022

Viewing posts 1–4 of 4

How to:
a) Hide [Upload files] by role?
b) Insert image from URL and display it at [Media Library] without upload?

Hi there,

a) WordPress has its won User Roles and Capabilities:

https://wordpress.org/support/article/roles-and-capabilities/

And there are a few functions you can use the remove_cap() function to remove them:

https://developer.wordpress.org/reference/classes/wp_role/remove_cap/

And you can use it in a PHP Snippet like so:


function remove_author_upload_media() {
	// get_role returns an instance of WP_Role.
	$role = get_role( 'author' );
	$role->remove_cap( 'upload_files' );
}
add_action( 'init', 'remove_author_upload_media' );

This removes the upload_files cap from the role of author

b) unfortunately i do not know how to do this. Have a look for a plugin for Advanced Media Manager

Thanks for help, resolved.

Glad to hear that!

This archived topic is closed to new replies.