Grant to Editor User role ability to edit and updated SmartCrawl settings

Please advise, how to grant to Editor user role an option to edit and save SmartCrawl settings

  • Lindeni Mahlalela

    Hello Portridge

    I hope you are doing great today and thank you for contacting us.

    By default, SmartCrawl has the ability to show SEO meta boxes in the post or page editor, you can choose to show or hide these meta boxes by user role in the SmartCrawl > Settings page like this:

    If you need to show the whole SmartCrawl dashboard to the editor, then you can do it by changing a line of code in the plugin. I have checked the code of the SmartCrawl plugin and it seems that the settings page is limited to users with the capability of 'list_users'. From the code I have seen it does not seem possible to change this without changing a few lines of code in the core. Even though this is not advisable but it seems to be the only option so far.

    public $capability = 'list_users';

    In the file wpmu-dev-seo/includes/admin/settings.php

    on line number 7, change it to:
    public $capability = 'editor';

    Then change the __construct function to look like this:

    protected function __construct() {
    	if( is_multisite() && WDS_SITEWIDE ) {
    		$this->capability = 'editor';

    And finally, change the init() function to look like this:

    public function init () {
    	global $wp_version;
    	$this->options = self::get_specific_options($this->option_name);
    	if (is_multisite() && defined('WDS_SITEWIDE') && WDS_SITEWIDE) {
    		$this->capability = 'editor';
    	add_action( 'init', array( $this, 'defaults' ), 999 ) ;
    	add_action( 'admin_body_class', array( $this, 'add_body_class' ) ) ;
    	if (is_multisite() &&  wds_is_switch_active('WDS_SITEWIDE') ) {
    		add_action('network_admin_menu', array($this, 'add_page') ) ;
    		add_action('admin_menu', array($this, 'add_page') ) ;
    	if (!is_multisite() || !(defined('WDS_SITEWIDE') && WDS_SITEWIDE) ) {
    		add_action('admin_menu', array($this, 'add_page') )  ;

    Then re-upload the file. After doing this, then all users with role "Editor" will see the SmartCrawl settings. I tested this on a single and multi site install and it worked for me, I hope it works for you.

    I hope this works, please let us know if you need any further assistance and we will always be happy to help.

    Have a nice day.

  • Lindeni Mahlalela

    Hello Portridge,

    I hope you are doing great today and I hope you had the chance to try out the code provided above.

    The code above will work as it is but there are things you should consider when editing the code:

    1. On line number 7 of the file, I suggested that you change the line to
    public $capability = 'editor';

    but then there is a small issue with that since the 'editor' is a role which means some roles may not access the menu if if they should, so instead of using the role, it is better to use the capability 'edit_others_posts' so that all roles with this capability will have access to the menu. So no, line number 7 should be like this:

    public $capability = 'edit_others_posts';

    2. It seems line number 7 was actually the only line necessary to be changed because the other suggested changes apply to super admins and are not necessary because editors do not have access to the network dashboard, so changing only line number 7 would do the job just fine.

    3. The setup wizard of SmartCrawl does not have to be visible to editor since only the site admin or network admin should be able to setup SmartCrawl using the setup wizard. So, the wizard menu should be removed for every one except admins. It can be used by adding the following code in an mu-plugin:

    add_action( 'admin_menu', function(){
       if( current_user_can( 'manage_options' ) ){
       remove_submenu_page( 'wds_wizard', 'wds_settings' );
    }, 9999 );

    Once this code is added then only admins should have access to the setup wizard.

    I am very sorry if the above suggestion have caused you any inconvenience and I hope this works is you wish it to work.

    Have a nice day.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.