2

How to add a logout option to the main nav menu (not to the top bar) in BuddyPress?

2
  • Are you using the supplied default theme?
    – ZaMoose
    Commented Apr 17, 2011 at 23:50
  • Yes, Im using the default theme. Commented Apr 18, 2011 at 12:06

1 Answer 1

2

Google is your friend. Here is a snippit I found I didn't test it but seems logical.

 // functions.php
function add_login_logout_link($items, $args)
{
  if(is_user_logged_in())
  {
    $newitems = '<li><a title="Logout" href="'. wp_logout_url('index.php') .'">Logout</a></li>';
    $newitems .= $items;
  }
  else
  {
    $newitems = '<li><a title="Login" href="'. wp_login_url('index.php') .'">Login</a></li>';
    $newitems .= $items;
  }
  return $newitems;
}
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);

Source

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.