[buddypress-trac] [BuddyPress] #5122: Add Login/Logout/Register links to Appearance > Menus

buddypress-trac noreply at wordpress.org
Fri Aug 23 16:36:21 UTC 2013

#5122: Add Login/Logout/Register links to Appearance > Menus
 Reporter:  ubernaut                 |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  1.9
Component:  Core                     |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
Changes (by imath):

 * cc: math.viet@… (added)
 * keywords:  needs-patch => has-patch needs-testing



 I think @ubernaut's idea is very interesting because, it's very easy to
 build a widget with a wp_nav_menu thanks to the Custom Menu Widget. So,
 using a wp_nav_menu can give 2 outputs one in the sidebar, and one in
 another theme's location - User has the choice. And this last feature is
 interesting in the case a theme is not using a sidebar.

 So i worked on a patch, i had an interesting night.

 I actually build 3 patches :
 - the first one was using a dropdown box to list the BuddyPress items and
 a javascript was listening to its change event to fill the 2 fields that a
 link wp_nav_menu uses except that i made them hidden fields. Problem in
 that case is that we have links and name but it's then quite difficult to
 identify the item is a BuddyPress one. And we need to as the items must be
 "dynamics". For instance if a user is logged in : the link is no more a
 login one but a log out and the register link should in this case not be
 - then, i built a huge one that was creating a custom post type that was
 available in wp_nav_menu but not in other part of the UI. This step was
 interesting as i've found very handy to use the buddypress()->bp_nav (i
 was also using the bp_options_nav in this patch) to populate the
 BuddyPress menu items. Using a custom post type makes it very easy to
 identify a menu item is a BuddyPress one, but i thought this was too heavy
 to use for a menu (the patch is creating pages and children pages).
 - Finally, i built this third one, it uses a custom walker in order to
 fill the classes attribute of a nav item by inserting some css classes
 that help me in identifying the slug of a BuddyPress item, then a filter
 helps me to dynamically get the current user BuddyPress nav links and to
 alternatively display a logout / login - register link(s).

 If you're interested in the first 2 patches, i've made them available on
 my dropbox

 In this ticket, i only attach the last one (5122.03.diff) because it's
 "the lightest" way i've found to make available a BuddyPress nav menu that
 seems to behave the right way.

 These are links to 2 screen captures :
 - the BuddyPress accordeon in the WP Nav Admin UI http://flic.kr/p/fApvYU
 - the result on front, in a wp_nav_menu widget ;) http://flic.kr/p/fAacez

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5122#comment:14>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list