[wp-hackers] Can you merge two menus? [SOLVED]
Peter van der Does
peter at avirtualhome.com
Wed Jun 15 21:55:13 UTC 2011
On Wed, 15 Jun 2011 15:52:40 -0400
Peter van der Does <peter at avirtualhome.com> wrote:
> Hi,
>
> I want to have two menus
> - Guests Menu
> - Members Menu
>
> The members menu is an exact copy of Guest plus some extra items.
>
> I know you can create two menus in admin but I would like to know
> if it's possible to create a Members menu which only holds those
> items available for members and merge these menu items with the guest
> menu when needed.
>
Here's what I did and it seems to work:
if (is_user_logged_in()){
add_filter('wp_nav_menu_objects', 'members_menu', 10, 2);
}
function rps_members_menu($sorted_menu_items, $args)
{
$header_members = wp_get_nav_menu_items('Header_members');
_wp_menu_item_classes_by_context( $header_members );
foreach ($header_members as $item) {
$sorted_menu_items[]=$item;
}
return $sorted_menu_items;
}
The Header_members only contains items for members.
Thanks to Mike Schinkel for getting me on the right track.
--
Peter van der Does
GPG key: CB317D6E
IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes
WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware
More information about the wp-hackers
mailing list