• ERALION

    (@freeben)


    Hi,

    I am a French web developer specialized in WordPress development and I recently met several times the same problem on different customers websites, without any specific relation between the sites except the branch 5.0.X of WordPress.

    As this seems to be a problem related to the version of WordPress and not to a specific plugin, I thought that sharing the solution could surely help those who will encounter the same problem here.

    This is a back-office access issue that during a connection attempt indicates the error: “You are not allowed to access this part of the site”

    No usual solution for this problem works: disable plugins, change the active theme, create a new admin user, etc …

    After many analyzes, I found that the capabilities of the administrator role had been completely erased, and there is no common plugin to the sites concerned.

    The solution/fix is to edit the functions.php file of its theme to add the following code:

    add_action( 'init', 'admin_fix' );
    function admin_fix() {
        if ( !function_exists( 'populate_roles' ) ) {
    		require_once( ABSPATH . 'wp-admin/includes/schema.php' );
    	}
    
    	populate_roles();
    }

    Once this code has been added to the file, and file uploaded, just run as a simple connection attempt to the back office for example, it will be refused but the code will be executed and access will be restored to the 2nd attempt.

    The code can then be removed from the functions.php file, or left as a precaution to avoid losing access again.

    • This topic was modified 6 years ago by ERALION.
    • This topic was modified 6 years ago by ERALION.
  • The topic ‘You are not allowed to access this part of the site’ is closed to new replies.