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:
1 2 3 4 5 6 7 8 |
# 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.
Featured Plugin - WordPress Q&A Site Plugin
It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more
Featured Plugin - WordPress Newsletter Plugin
Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more
Featured Plugin - WordPress Pop-Up Chat Plugin
No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more
Featured Plugin - WordPress Wiki Plugin
To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more
Featured Plugin - WordPress Appointments Plugin
Take, set and manage appointments and client bookings without having to leave WordPress. Appointments+ makes it easy.
Find out more
Featured Plugin - WordPress Ecommerce Shopping Cart Plugin
Out of all the WordPress ecommerce plugins available, MarketPress has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more
Featured Plugin - WordPress Google Maps Plugin
Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more
Featured Plugin - WordPress Membership Site Plugin
If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more
Featured Plugin - WordPress Facebook Plugin
Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more
Awesome tips – Im a subscriber.
My facebook id are hack. Please suggest me……
i need……..
Contact us: kishshee@gmail.com
Hi there,
I did this and it completely crashed my site!!
I added this to the functions.php file just before the final ?>:
$edit_contributor->add_cap(‘upload_files’);
$edit_contributor->remove_cap(‘delete_posts’);
and then got a fatal error. I couldn’t get back to my wordpress dashboard or my site at all.
Eventually after some panic I logged onto the host server (which I have virtually never done) with some difficulty found the functions.php file and removed the 2 lines.
The site now works again.
I’d really like this to work and have no idea why it caused my site to crash – any ideas?
thanks,
Alan