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
    Commented Jun 23, 2014 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
    Commented Jun 23, 2014 at 22:03

1 Answer 1

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 and acknowledge you have read our privacy policy.

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