Lokesh Verma
Lokesh Verma

Reputation: 51

Allow contributor role to upload images but not able to edit already published articles in wordpress

I am trying to add a feature in my wordpress website:

The Contributor role can upload images but not able to edit already published articles and images.

I have tried code but this is only enable media upload but contributor can delete his own uploaded media of published articles.

if ( current_user_can('contributor') && !current_user_can('upload_files') )
    add_action('admin_init', 'allow_contributor_uploads');

function allow_contributor_uploads() {
    $contributor = get_role('contributor');
    $contributor->add_cap('upload_files');
}

Upvotes: 0

Views: 85

Answers (1)

Gnanasekaran Loganathan
Gnanasekaran Loganathan

Reputation: 1108

Use this plugin you can give any access to any role.
https://wordpress.org/plugins/user-role-editor/

Upvotes: 1

Related Questions