Page 1 of 1

display username on menu list

Posted: Sun Oct 28, 2012 10:02 am
by made

how to display username that logged on into menu list?
etc:
Welcome John, menu1, menu2, menu3, logout

thanks in advanced


Re: display username on menu list

Posted: Mon Oct 29, 2012 9:54 am
by Webmaster

Customize ewmenu.php and echo CurrentUserName() above the menu.


Re: display username on menu list

Posted: Tue Oct 30, 2012 1:53 pm
by made

can it be done on custom code?
not manually after the page has been generated


Re: display username on menu list

Posted: Wed Oct 31, 2012 12:07 am
by Nicole

try this, it's working for me...

MenuItem_Adding server event:

 if ($Item->Id == -1 ) {
        if (IsSysAdmin() )
            $user="Administrator";
        else
            $user = $Security->CurrentUserInfo("vorname")." ".$Security->CurrentUserInfo("name"); // Note: change to your own field names in the user table
    
        if (IsLoggedIn() ) {       
            $Item->Text = '<img border="0" src="phpimages/door_in.png" width="12" height="12" align="top">&nbsp;<b>Logout</b>&nbsp;('.$user.')';
            $Item->ParentId = 18; // Account // Note: moves the "logout" to another menu-level, change to your own parent menu item ID
        }
}

NOTE: This piece of code moves the "logout" to another menu-level and is adding an icon and the name of the user.


Re: display username on menu list

Posted: Wed Oct 31, 2012 10:53 pm
by jacson

i test it
its not working
and logout word is removed from menu


Re: display username on menu list

Posted: Fri Nov 09, 2012 9:46 am
by sal1150

Customize template.php and add this :

<!-- header (begin) --><!-- *** Note: Only licensed users are allowed to change the logo *** -->

<div class="ewHeaderRow"><img src="phpimages/mylogo.png" alt="" border="0">
&nbsp;&nbsp;&nbsp;
<?php if (IsLoggedIn()) { ?>
<!-- display username -->
<span class="phpmaker"> Welcome: <? echo($_SESSION[EW_SESSION_USER_NAME]);?></span>


Re: display username on menu list

Posted: Mon Nov 12, 2012 12:09 am
by erzon

Try this in Menu_ItemAdding

after the }

type

if ( IsLoggedIn() )
{
echo "Hi, <b> ".CurrentUserInfo("Name");

}

just change the Name to your user field


Re: display username on menu list

Posted: Mon Nov 12, 2012 11:46 am
by jacson

thank you erzon
yes it's working fine but hi word repeat many


Re: display username on menu list

Posted: Tue Nov 13, 2012 12:08 am
by erzon

maybe you can post your code.. this code is working for me without any problem


Re: display username on menu list

Posted: Tue Nov 13, 2012 12:34 pm
by jacson

thank you erzon

in server event

menuitem_adding

function MenuItem_Adding(&$Item) {
if ( IsLoggedIn() )
{
echo "Hi, <b> ".CurrentUserInfo("Name");

}

return TRUE;

}

in web appear
Hi jacson, Hi jacson, Hi jacson, Hi jacson, Hi jacson,Hi jacson, Hi jacson, Hi jacson, Hi jacson,


Re: display username on menu list

Posted: Wed Nov 14, 2012 12:14 am
by Nicole

The server event menuitem_adding is called as many times as you have menu-items.

You need a logic wich show your echo only one time. Look at my first post!!!


Re: display username on menu list

Posted: Wed Nov 14, 2012 1:47 am
by aburajeh

jacson wrote:
i test it
its not working
and logout word is removed from menu

Hi Nicole,
thank you advance

You code Not work stop at line 26 > >> if (IsLoggedIn() ) {

You can fixed

Thank you again


Re: display username on menu list

Posted: Fri Nov 16, 2012 3:41 pm
by erzon

put the code in Menu_Rendering and remove the return true statement it should work fine


Re: display username on menu list

Posted: Fri Jun 07, 2013 8:14 am
by cahilbey

Thank you all, this works fine for me:

function Menu_Rendering(&$Menu) {
if (IsLoggedIn()){
echo "Welcome back ".CurrentUserName();
}
}


Re: display username on menu list

Posted: Wed Jun 12, 2013 4:04 pm
by sobrigas

You can add "Menu Editor", ex: user.

//function MenuItem_Adding

if (IsLoggedIn() ) {
$user = CurrentUserName();
if($Item->Text == 'user') {
$Item->Text = "Hi, <b>" . $user . "</b>";
}
}


Re: display username on menu list

Posted: Tue Aug 13, 2013 5:31 pm
by Aburajeh

cahilbey wrote:
Thank you all, this works fine for me:

function Menu_Rendering(&$Menu) {
if (IsLoggedIn()){
echo "Welcome back ".CurrentUserName();
}
}

IS WORK THANK YOU