PeachPay

Sponsored

WP Mayor is supported by its audience. Our recommendations are based on our experts’ research and hands-on testing. If you purchase through a link on our website, we may earn a commission. Here’s why you can trust us.

How to Limit WP-Admin Functionality for the Contributor Role

  Introduction
If you run a multi-author blog and you're letting other writers pen their articles directly in your blog's wp-admin, you will probably want to limit their access to what they can see or do. Here's a look at how I do that on my WordPress sites.
WP Mayor is supported by its audience. Our recommendations are based on our experts’ research and hands-on testing. If you purchase through a link on our website, we may earn a commission. Here’s why you can trust us.
 Table of contents
How to Limit WP-Admin Functionality for the Contributor Role

If you run a multi-author blog and you’re letting other writers pen their articles directly in your blog’s wp-admin, you will probably want to limit wp-admin functionality – in other words, their access to what they can see or do.

By default, the contributor role, which is the most likely role you’re going to be using for these guest authors, allows access to some things that I don’t think should be accessible in most cases.

Here’s how I address it on my own WordPress sites.

How to Limit WP-Admin Functionality

Security Logging

The first thing I always do on such blogs is to install the WP Security Audit Log plugin. This is a magnificent plugin that shows all actions taken by any user within your blog.

WP Security Audit Log Plugin

I’m of the opinion that if you are running a multi-author blog, this is one of the essential plugins you should be using. In fact, for me, it’s as essential as an SEO plugin on such blogs. Heck, I also use it on any other WordPress site I build because I place a high emphasis on security and logging for my sites.

How to Check What Another User Can See

With that plugin installed, the next plugin I’ll install is User Switching (free). This permits me to easily switch to any specific user registered on my website. I can, therefore, check how the dashboard looks for that user and customize it accordingly.

Customizing the User Role & Capabilities

Next, I need an easy way to customize the dashboard and remove items that the user should not have access to. For that, I use the free plugin called Adminimize.

It enables you to edit all the capabilities associated with a user role using a number of checkboxes. It’s simple enough to figure out once you install it.

Additionally, I install the Code Snippets plugin and add a few snippets as follows.

First, we need to enable media uploads for the contributor role:

// Allow Contributor Role to Upload Media

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

Then I also want to disable the contributor’s ability to view other posts written by different authors in wp-admin. For this, I use the following code snippet:

function posts_for_current_author($query) {
    global $pagenow;
 
    if( 'edit.php' != $pagenow || !$query->is_admin )
        return $query;
 
    if( !current_user_can( 'edit_others_posts' ) ) {
        global $user_ID;
        $query->set('author', $user_ID );
    }
    return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');

That’s It

By using the above methods, I can rest assured that contributors have what they need to prepare their content and just that. This is not limited to just the Contributor role, of course, so the same can be applied to other user roles and capabilities depending on your needs.

Have you struggled with this yourself? Had you found a different solution? Let us know in the comments below.

Jean Galea
Jean Galea
Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.
Recommended For You
Recommended For You
Get more expert advice like this delivered to your inbox every week.
Join thousands of designers, developers, and marketers who trust our experts to find and test the best tools and services for your website.
By signing up to our newsletter, you agree to receive electronic communications from WP Mayor that may include advertisements.
Get more expert advice like this delivered to your inbox every week.
Join thousands of designers, developers and marketers who trust our experts to find and test the best tools to build, improve, and optimize their websites.
By signing up to our newsletter, you agree to receive electronic communications from WP Mayor that may include advertisements.
Join the Conversation

Leave a Reply

Your email address will not be published.

From web hosting to WooCommerce plugins and backup services, we have put together a collection of exclusive coupons and deals just for you.
WP Mayor_Icon_white

Reader Survey

Supercharge your WooCommerce store!