expandedfronts / revisr

Revisr: Git for WordPress
https://revisr.io
GNU General Public License v3.0
195 stars 41 forks source link

"You do not have sufficient permissions to access this page." #91

Closed jonlambert closed 8 years ago

jonlambert commented 8 years ago

Hi,

Recently the plugin menu has disappeared from the primary admin navigation, and any attempts to visit the "Settings" page directly via Plugins yields the message:

"You do not have sufficient permissions to access this page."

Do you have any ideas what might be going on? The rest of the website is functioning correctly!

Markovnin commented 8 years ago

@jonlambert I have the same issue. Did you manage to fix it?

mattgrshaw commented 8 years ago

Haven't been able to replicate this - closing due to inactivity. Please reopen if this still occurs.

MDCore commented 8 years ago

I may have been able to reproduce this issue. We've turned off plugin installation via the admin because we manage that via composer. Unfortunately revisr won't seem to work without that:

            if ( current_user_can( self::get_capability() ) && is_admin() ) {
                    self::$instance->load_admin_hooks();
            }

    /* snip */
    public static function get_capability() {
            return apply_filters( 'manage_revisr', 'install_plugins' );
    }

I'm not sure why it's looking for the ability to install plugins. I change get_capability() to simply return true and I was able to see the menu and get as far as setup.

mattgrshaw commented 8 years ago

Good catch. It will do that if you don't have that permission. It checks for the install_plugins permission since if a user doesn't have permission to install plugins, they likely shouldn't be able to play around with Git and potentially destroy the site.

The permission it checks for is filterable though so you can change it to check for any other permission, just add the following in your theme's functions.php or a custom plugin:

function custom_revisr_capability() {
    return 'some_other_permission';
}
add_filter( 'manage_revisr', 'custom_revisr_capability' );

Possible capabilities: https://codex.wordpress.org/Roles_and_Capabilities

MDCore commented 8 years ago

Brilliant! This works perfectly. In our case I know that our admin users can be trusted to use git, so I simply set custom_revisr_capability to return true.

Thanks for the lightning fast response :+1: