Admin – Load existing admin template as a submenu page

I’m trying to save my client a few clicks. I’ve created a custom role of “Customer” and I’d like to get them to that screen, without having to have them click “Users” and then select the “Customer” role.

So, I have a custom menu called “Orders”. I’d like to add a submenu called “Customers” and “load” this page:

Read More

users.php?role=custom

I’m guessing I have to use the callback function on add_submenu_page and then load that template? What’s the right way to go about this?

Related posts

Leave a Reply

1 comment

  1. You can add an interal link quite easily, it’s the same approach you use for adding custom items, you simply exclude a callback function and set the menu slug to the applicable URL, here’s an example.

    add_action( 'admin_menu', 'add_user_type_link' );
    function add_user_type_link() {
        add_submenu_page( 'users.php', 'Customers', 'Customers', 'edit_users', 'users.php?role=customers' );
    }
    

    Adjust the code as appropriate(required cap, naming, etc..).