• hi I have a login on top o my nav bar.
    the only thing i miss is a welcome text when a user is logged in.

    can you achieve that with this code?

    function add_login_logout_link($items, $args)
    {
    if( $args->theme_location == 'Top Navigation' ) {
      if(is_user_logged_in())
      {
        $newitems = $items;
        $newitems .= '<li><a title="Logout" href="'. wp_logout_url('index.php') .'">Logout</a></li>';
      }
      else
      {
        $newitems = $items;
        $newitems .= '<li><a title="Login" href="'. wp_login_url('wp-admin/index.php') .'">Login</a></li>';
      }
    
      return $newitems;
     } else {
       return $items;
     }
    }
    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
  • The topic ‘login welcome text’ is closed to new replies.