This topic is locked

How change 'Logged on as' message

11/17/2010 2:01:29 PM
PHPRunner Tips and Tricks
Sergey Kornilov admin

This message can be changed in the List page: Before display event on the Eventstab. Here is how you can display user full name instead of username (make sure to replace field and table names with real ones):

$rs=CustomQuery("select FIRST_NAME, LAST_NAME from LoginTableName where UserName='".$_SESSION["UserID"]."'");

$data=db_fetch_array($rs);

$xt->assign("username",$data["FIRST_NAME"]." ".$data["LAST_NAME"]);
ficcionista 12/28/2010



This message can be changed in the List page: Before display event on the Eventstab. Here is how you can display user full name instead of username (make sure to replace field and table names with real ones):

$rs=CustomQuery("select FIRST_NAME, LAST_NAME from LoginTableName where UserName='".$_SESSION["UserID"]."'");

$data=db_fetch_array($rs);

$xt->assign("username",$data["FIRST_NAME"]." ".$data["LAST_NAME"]);



Hi, since I usually create a single field for first and last names, my code is a bit simpler, but i guess it could be made to work with two fields also.

Here's my example:
Event "After successful login"

function AfterSuccessfulLogin($username,$password,$data)

{

$_SESSION["FullName"] = $data["name"];

} // function AfterSuccessfulLogin


Event "List page: Before display"

function BeforeShowList($xt,$templatefile)

{

$xt->assign("username",$_SESSION['FullName']);

} // function BeforeShowList


We could also try this if you have first and last name in two separate fields (Haven't tried it yet, so I can't confirm if it works):

function AfterSuccessfulLogin($username,$password,$data)

{

$_SESSION["FullName"] = $data["first_name"]." ".$data["last_name"];

} // function AfterSuccessfulLogin
R
robfontan 12/29/2010



This message can be changed in the List page: Before display event on the Eventstab. Here is how you can display user full name instead of username (make sure to replace field and table names with real ones):

$rs=CustomQuery("select FIRST_NAME, LAST_NAME from LoginTableName where UserName='".$_SESSION["UserID"]."'");

$data=db_fetch_array($rs);

$xt->assign("username",$data["FIRST_NAME"]." ".$data["LAST_NAME"]);



Hi Sergey. I found the answer. It was my mistake as I added the code to the Before Process event instead of Before Display. Sorry to bother you. The problem has been solved.
Thank you !

---------------------------------------------------

This was the original post:
Hi Sergey. I did that but I get the following PHP error: Undefined variable: xt
This is my code in List Page Before process:
$rs = CustomQuery("select Lastname, Firstname from mdl_user where UserName='".$_SESSION["UserID"]."'");

$data = db_fetch_array($rs);

$xt->assign("username",$data["Firstname"]." ".$data["Lastname"]);
What could be wrong?

Thanks.

T
Tayyab Ilyas 11/2/2013

How Can we display image of user with logged in as?

Sergey Kornilov admin 11/4/2013

Tayyab,
I guess instead of

$xt->assign("username",$data["FIRST_NAME"]." ".$data["LAST_NAME"]);



you can use something like:

$xt->assign("username","<img src='full URL of image file'> ".$data["FIRST_NAME"]." ".$data["LAST_NAME"]);
T
Tayyab Ilyas 11/4/2013

Great It worked !!!

Bud to i need to do this code for all list pages manually or is there any workaround?