How to Limit WPAdmin Functionality for the Contributor Role –

How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor

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.

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.

How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor 1

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.

How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor 2

Related Articles

  • How to Remove Menu Items in Admin Depending on User Role

    So lets say you open up your blog to guest posters, and you create a user for them, and possibly even a custom role. You will usually find one or…

  • How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor 3

    Last week you had a chance to participate in the WP User Frontend PRO Giveaway, which thanks to you, was very successful! Today we are happy to announce our winners!

  • How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor 4

    We recently came across WP Clicks an amazing plugin for WordPress than can really help you garner more information about the way visitors are interacting with your website. I see…

  • How to Limit WP-Admin Functionality for the Contributor Role - WP Mayor 3

    I bet you were missing our giveaways, since we didn’t run one for a couple of weeks. Today I am pleased to announce the event of the week – WP…

Keep reading the article at WP Mayor. The article was originally written by Jean Galea on 2020-05-13 07:00:00.

The article was hand-picked and curated for you by the Editorial Team of WP Archives.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

Your email address will not be published. Required fields are marked *

Show Your ❤️ Love! Like Us
Scroll to Top