1

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:

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?

1 Answer 1

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..).

3
  • NOTE: Alternatively you can use add_users_page in place of add_submenu_page.
    – t31os
    Oct 20, 2011 at 17:54
  • Thanks for this! I had tried this unsuccessfully prior - I probably missed something, though, I'll give it a shot and report back. Oct 21, 2011 at 21:32
  • 1
    It worked! Beautiful! In my case, I wanted it under my custom menu, so I used "manage-reports" (the slug of my custom menu) instead of "users.php". Oct 31, 2011 at 16:45

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.