Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
NOTE: Alternatively you can use add_users_page in place of add_submenu_page. –  t31os Oct 20 '11 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. –  Jonathan Wold Oct 21 '11 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". –  Jonathan Wold Oct 31 '11 at 16:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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