Network Admin “You do not have sufficient permissions to access this page.”

The easiest way to restore Super Admin privileges is to add a bit of code to your theme’s functions.php file to add yourself back: include(ABSPATH . ‘wp-admin/includes/ms.php’); $user = get_userdatabylogin(‘YOUR_USERNAME’); grant_super_admin($user->ID); Once your Super Admin privileges have been restored you can remove this code from your theme.

How to stop wordpress from changing default .htaccess permissions to 444

Your site has likely been hacked. My site had the Darkleech infection, which injected some malicious code into wp-includes/nav-menu.php, causing .htaccess to reset to 444 on any page load. I’d recommend you install the Sucuri plugin and let it restore any files that have been corrupted. Assuming your site was hacked, use their Post-Hack tab … Read more

add_menu_page permissions – what am I doing wrong?

You want the admin_menu hook, rather than admin_init. Also, you shouldn’t use anonymous functions. Instead, use: function wpse51004_add_menu_page() { add_menu_page(‘Some Page’, ‘Some Page’, ‘manage_options’, ‘some-slug’, ‘wpse51004_some_page_callback’); }; add_action(‘admin_menu’, ‘wpse51004_add_menu_page’); function wpse51004_some_page_callback() { echo ‘Hello, world!’; }

Add Custom User Capabilities Before or After the Custom User Role has Been Added?

There’s a reason why add_role() has the $capabilities as 3rd parameter. First some insights on what happens, when you use the function. It calls WP_Roles->add_role() – the class method The method then does a check if the role already exists. If yes, it aborts. The next step is, that it adds the role to WP_Roles->roles[] … Read more

WordPress REST API – Permission Callbacks

The issue was because I wasn’t generating and sending a nonce value with the request. In order to generate a nonce value. Localize the value of a wp_create_nonce(‘wp_rest’) function call. wp_localize_script(‘application’, ‘api’, array( ‘root’ => esc_url_raw(rest_url()), ‘nonce’ => wp_create_nonce(‘wp_rest’) )); This will then be accessible to the window object of the browser which can be … Read more