How do I change which users have access to Link Whisper?

  1. Home
  2. Knowledge Base
  3. Technical Guides
  4. How do I change which users have access to Link Whisper?

How do I change which users have access to Link Whisper?

By default, most of Link Whisper’s functionality is restricted to users that have the “manage categories” capability. Since Editors are the lowest user role that can edit categories, this restricts Link Whisper to Editors and above.

To make Link Whisper available to users with different capabilities, we have created a filter so you can set the minimum capability requirement.

If for example, your authors have the “edit posts” capability, this piece of code will make Link Whisper available to them.

/* Adjusts the Link Whisper permissions check so users with the "edit posts" capability are able to use the plugin */
add_filter('wpil_filter_main_permission_check', 'link_whisper_adjust_main_permission', 10, 1);
function link_whisper_adjust_main_permission($capability = ''){
    $capability = 'edit_posts';
    return $capability;
}

To install it, you’ll need to either use a code snippet plugin , or if you’re using a child theme paste it into the child theme’s functions.php file.

(For a list of the different WordPress capabilities, and how they relate to default roles, please check out this article)

Controlling feature access.

You can control what major features of Link Whisper users have access to by using an additional filter.

The filter is called “wpil_filter_menu_listings”, and it allows you to filter what features of Link Whisper are accessible from the Dashboard menu.

The list of available items are:

  • ‘link_whisper_inbound_internal’, // The Links Report
  • ‘link_whisper_autolinking’, // The Autolinking
  • ‘link_whisper_target_keywords’, // The Target Keyword Report
  • ‘link_whisper_url_changer’, // The URL Changer
  • ‘link_whisper_settings’, // The Link Whisper Settings

Removing any of them from the list will remove it’s associated feature. The Dashboard page is always available because it’s needed as an anchor for the other menu items.

If for example, you want to remove the Autolinking from users that don’t have the ability to publish posts, you can use custom code such as this:

 

/**
 * Filters the Link Whisper menu items to remove the Autolinking for any users that don't have the ability to publish posts
 **/
add_filter('wpil_filter_menu_listings', 'link_whisper_filter_menu_items');
function link_whisper_filter_menu_items($menus){
    // if the current user can't publish posts, and the autolinking is in the list of items
    if(!current_user_can('publish_posts') && in_array('link_whisper_autolinking', $menus, true)){
        // find the autolinking menu in the list of menus
        $key = array_search('link_whisper_autolinking', $menus);
        if($key !== false){
            // and remove it from the menu list
            unset($menus[$key]);
        }
    }
    return $menus;
}

 

Now any users that don’t have the permission to publish posts won’t be able to access the Autolinking:

Build A Powerful Internal Link Strategy Today

Enter your email & we'll send you 8 tips to build an internal link strategy.

And 3 things you should avoid doing with internal links.

    We won't send you spam. Unsubscribe at any time.

    Was this article helpful?

    Related Articles

    Need Support?

    Can't find the answer you're looking for?
    Contact Support

    Get Started with LinkWhisper

    Speed Up the Process of Internal Linking and Help You Rank Better in Google

    Get LinkWhisper Now