Top

Daily Tip: How to Customize WordPress Roles and Capabilities Without Hacking the Core

November 14, 2010

Here’s a handy tip for site admins who want to customize what user roles can and cannot do. The best thing is that you can make these changes without hacking the WordPress core. You can add the changes directly to your functions.php file. Here are a few examples, courtesy of wp-snippets.com:

# 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');

It’s important to note here that these capabilities are written to the database. If you need to give back a capability to a role, you have to use the add_cap-function.

Tweet This Post

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.