1

Here is some of my code:

class proposal {

function __construct() {
    add_menu_page('Topic Proposal', 'Topic Proposal', 'read', 'topic_proposal', array(&$this, 'writer_page'), 'dashicons-welcome-add-page');
}

public function load_menu() {
    echo 'EHY';
}

public function writer_page() {
    ?>
        <h1>Topic Proposal</h1>
    <?php
}

public function editor_page() {
    ?>
        <h1>Topic Proposal</h1>
    <?php
}

}

add_action( 'admin_init', function(){return new proposal();});

The "Topic Proposal" shows of on the menu but when I click on it I get this:

You do not have sufficient permissions to access this page.

What am I doing wrong?

2
  • 1
    have you read add_menu_page in codex?
    – Milo
    Jun 23 '14 at 21:39
  • I imagine. The "Topic Proposal" does show in the menu so in parts "add_menu_page" works it's just when I try to open the page it does not work.
    – jnbdz
    Jun 23 '14 at 22:03
1

From add_menu_page in Codex:

Note: If you're running into the "You do not have sufficient permissions to access this page" error, then you've hooked too early. The hook you should use is admin_menu.

admin_init is too early to hook add_menu_page, use admin_menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.