• I’m trying to create a custom menu visible to multisite users without a blog. I already have a working minimal test, which I can display to users with a blog:

    add_action('admin_menu', 'test_user_admin_menu');
    function test_user_admin_menu() {
        add_menu_page('Test Menu', 'Test Menu',
            null, 'test', 'test_user_admin_page');
    }
    function test_user_admin_page() {
        echo "<h2>Hello world</h2>";
    }

    Based on codex, to make this menu appear to network users without a blog I need to hook into user_admin_menu action. I verified that I’m using the right hook by changing the first line of the above code to:

    add_action('user_admin_menu', 'test_user_admin_page');

    This does produce “Hello world” heading on loading dashboard for such user. However, changing the line to:

    add_action('user_admin_menu', 'test_user_admin_menu');

    produces no menu or output of any kind….

    Where am I going wrong? Could somebody please give me a clue?

Viewing 1 replies (of 1 total)
  • Thread Starter umka.dk

    (@umkadk)

    Ok, after digging around a bit more, I finally managed to solve my own problem: in order for the menu to appear add_menu_page() needs to know the lowest possible capability for which to display that menu….

    As it turns out, the lowest capability for a network user without a blog is 'exist' and not null. Thus, my origin code works provided I change the add_menu_page() line to:

    add_menu_page('Test Menu', 'Test Menu',
        'exist', 'test', 'test_user_admin_page');
Viewing 1 replies (of 1 total)
  • The topic ‘Hooking into user_admin_menu fails to add menu.’ is closed to new replies.