display username on menu list
how to display username that logged on into menu list?
etc:
Welcome John, menu1, menu2, menu3, logout
thanks in advanced
how to display username that logged on into menu list?
etc:
Welcome John, menu1, menu2, menu3, logout
thanks in advanced
Customize ewmenu.php and echo CurrentUserName() above the menu.
can it be done on custom code?
not manually after the page has been generated
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"> <b>Logout</b> ('.$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.
i test it
its not working
and logout word is removed from menu
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">
<?php if (IsLoggedIn()) { ?>
<!-- display username -->
<span class="phpmaker"> Welcome: <? echo($_SESSION[EW_SESSION_USER_NAME]);?></span>
Try this in Menu_ItemAdding
after the }
type
if ( IsLoggedIn() )
{
echo "Hi, <b> ".CurrentUserInfo("Name");
}
just change the Name to your user field
thank you erzon
yes it's working fine but hi word repeat many
maybe you can post your code.. this code is working for me without any problem
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,
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!!!
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
put the code in Menu_Rendering and remove the return true statement it should work fine
Thank you all, this works fine for me:
function Menu_Rendering(&$Menu) {
if (IsLoggedIn()){
echo "Welcome back ".CurrentUserName();
}
}
You can add "Menu Editor", ex: user.
//function MenuItem_Adding
if (IsLoggedIn() ) {
$user = CurrentUserName();
if($Item->Text == 'user') {
$Item->Text = "Hi, <b>" . $user . "</b>";
}
}
cahilbey wrote:
Thank you all, this works fine for me:
function Menu_Rendering(&$Menu) {
if (IsLoggedIn()){
echo "Welcome back ".CurrentUserName();
}
}
IS WORK THANK YOU