Change WordPress user roles and capabilities Forums Give user access to plugin – how to WordPress Posts Bulk Editor Professional not appearing in dashboard sidebar menu

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7428
    TWalker
    Participant

    I cannot get this plugin (WordPress Posts Bulk Editor Professional) to show for my custom user roles. Neither in the admin bar or in the dashboard sidebar. I have emailed the plugin to support@ – thank you for your help.

    #7430
    Vladimir
    Keymaster

    WPBE plugin developer decides that this plugin should be available only to users with ‘administrator’ or ‘editor’ role. Instead of user capability, which you would grant to any custom role, plugin checks directly ‘administrator’ and ‘editor’ role before add its menu page:

    
    if (WPBE_HELPER::can_manage_data()) {
        add_action('admin_menu', function() {
                    add_menu_page(esc_html('WPBE Bulk Editor', 'bulk-editor'), esc_html('WPBE Bulk Editor', 'bulk-editor'), 'publish_posts', 'wpbe', function() {
                        $this->print_plugin_options();
                    }, 'dashicons-hammer', 90);
                }, 99);
    }
    
    
    public static function can_manage_data($user_id = 0) {
    
        if ($user_id === 0) {
            $user = wp_get_current_user();
        } else {
            $user = get_userdata($user_id);
        }
        // !!! this condition does not allow custom roles to use this plugin 
        if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) {
            return TRUE;
        }
    
        return FALSE;
    }
    
    
    #7431
    TWalker
    Participant

    So are you saying there is no way to get this plugin to work with your plugin? Is there no fix?

    #7432
    Vladimir
    Keymaster

    Fix is possible, if you are ready to edit this plugin code.
    Replace can_manage_data() function at bulk-editor/classes/helper.php file (#356) with the version below. It allows to use plugin to any user who can ‘edit_others_posts’:

    
        public static function can_manage_data($user_id = 0) {
    
            if ($user_id === 0) {
                $user = wp_get_current_user();
            } else {
                $user = get_userdata($user_id);
            }
    /*
            if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) {
                return TRUE;
            }
    */
            if ( current_user_can('edit_others_posts') ) {
                return TRUE;
            }
    
            return FALSE;
        }
    
    

    Take into account that you have to repeat this editing after any plugin update.

    #7433
    Vladimir
    Keymaster

    Update: as function can accept parameter $user_id, we have to check not current user only, but a user with ID equal $user_id value:

    
        public static function can_manage_data($user_id = 0) {
    
            if ($user_id === 0) {
                $user = wp_get_current_user();
            } else {
                $user = get_userdata($user_id);
            }
    /*
            if (in_array('administrator', $user->roles) OR in_array('editor', $user->roles)) {
                return TRUE;
            }
    */
            if ( user_can( $user, 'edit_others_posts') ) {
                return TRUE;
            }
    
            return FALSE;
        }
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.