WordPress Error: You are not allowed to access this page

2022/06/19 22:53


When you got this error, there maybe two reasons.

Reason 1

The capability is not correctly set.

You can change the capability to  $capability = ‘read’; and refesh the page.

function name_search()
    $page_title = __('Search Name', 'mobilegogo');
    $menu_title = __('Search Name', 'mobilegogo');
    $capability = 'read';
    $menu_slug = 'name-search';
    $function = 'name_search_page';
    $position =2;
    add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function, $position );

Reason 2

The admin page is not included in function.php. In this case, you can use require_once or similar function to inlude your page.


Leave a Reply

Back to top