Home Forums Unicon Topbar add loginname via php

Home Forums Unicon Topbar add loginname via php

  • Creator
    Ticket
  • #89832
    DStatG
    Buyer

    Hello,

    I want to show the login name of the users in the topbar.
    Here is the code which i use in the functions php:

    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item');
    function my_custom_menu_item($items)
    {
        if(is_user_logged_in())
        {
            $user=wp_get_current_user();
            $name=$user->display_name; // or user_login , user_firstname, user_lastname
            $items .= '
  • Welcome '.$name.'
  • '; } return $items; }

    But now the “Welcome xy” is in all menus, how can i refere only to the topbarmenu?

    Thanks,
    Felix

Sorry, only verified customers can view ticket replies.