X

Change Role Capabilities

There are several roles you can give your users in WordPress, like Contributor, Author or Administrator. These are pre-defined and has certain capabilities. To change these capabilities and create your own, customized user roles, just add the following to functions.php:

The different roles and capabilities are listed in the WordPress Documentation.

IMPORTANT! The capabilities are written to the database, so if you want to give back a capability to a role, you have to use the add_cap-function.

Code Snippet:

<?php
# Get the user role #
$edit_contributor = get_role('contributor');
# Contributor can upload media #
$edit_contributor->add_cap('upload_files');
# Contributor can no longer delete posts #
$edit_contributor->remove_cap('delete_posts');
?>

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!