Guest User

GP login/logout sec. nav

a guest
Oct 24th, 2016
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Add login/logout to secondary nav
  2. function add_login_logout_register_menu( $items, $args ) {
  3.  if ( $args->theme_location != 'secondary' ) {
  4.  return $items;
  5.  }
  6.  
  7.  if ( is_user_logged_in() ) {
  8.  $items .= '<li><a href="' . wp_logout_url() . '">' . __( 'Logga Ut' ) . '</a></li>';
  9.  } else {
  10.  $items .= '<li><a href="' . wp_login_url() . '">' . __( 'Logga In' ) . '</a></li>';
  11.  $items .= '<li><a href="' . wp_registration_url() . '">' . __( 'Registrera dig' ) . '</a></li>';
  12.  }
  13.  
  14.  return $items;
  15. }
  16.  
  17. add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 199, 2 );
RAW Paste Data