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.

GOAL: I want to use custom menus for two different kinds of users. For instance, I want to Merchant users to be able to use Merchant menu, and Owner for Owner menu.

I do not have enough reputation, this image is in the admin menu panel which has theme location with custom menu selection. http://dl.dropbox.com/u/6520543/custom%20menu.jpg

  1. wp_terms holds names of custom menus with term_id.
  2. wp_term_taxonomy holds term_id from wp_terms with taxonomy as "nav_menu" and number of menu items saved under each custom menu as count column.

"function register_custom_nav" and "register_nav_menus" work, but I can't find a clue how it selects which custom menu is selected for users. If I can find where it's loading the selected custom menu somewhere in the code or db, I can just change upon user's login. I think it's definitely in the DB where it selects the custom menu id, but I can't find.

Does anyone know how????

share|improve this question

1 Answer 1

Here is what i do when i need different menus for different users, i create a role for each user type (in your case Merchant and Owner) and i give each role a different view menu capability ex:

add_role('merchant', 'Merchant', array(
    'merchant_menu' => true // would allow the merchant to view merchant menu
));
add_role('owner', 'Owner', array(
    'owner_menu' => true // would allow the owner to view owner menu
));

and then i simply create 3 menus and instead of calling wp_nav_menu() by location i call it by name:

if ( current_user_can('merchant_menu') ) { //current user is a merchant
    wp_nav_menu(array('menu' => 'Merchant Menu Name' ));
}elseif(current_user_can('owner_menu') ){ //current user is an owner
    wp_nav_menu(array('menu' => 'Owner Menu Name' ));
}else{//any one else get the default menu
    wp_nav_menu(array('menu' => 'Default Menu' ));
}
share|improve this answer
    
Thanks @Bainternet, I think that should work, too. I will try and post result here as well. –  handicop Jun 12 '12 at 0:05

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.