This topic is locked
[SOLVED]

Insert user name into a record

2/18/2026 15:18:40
General Tips and Tricks
S
Simtrain author

I have a username field in all my tables, and when the logged on user edits or adds a record I would like that users name to be inserted into added/edited record. I know to use before add or before edit, but nothing I do seems to work.

Any help will be gratefully recieved.

Steve

Tandy 2/18/2026

In Events - Global Pages - Login Page - After Successful Login
Put in your session like this:
$_SESSION["UserName"] = $data["username"];

Then in your Fields - Whatever table for your Username field click on Properties Box Pick Readonly Then in the Default value use $_SESSION["UserName"] Or click on the ... and in drop down at the top pick Username and it marks it for you. Same for add and edit.

Sergey Kornilov admin 2/19/2026

The easiest option is to use BeforeAdd/BeforeEdit event and update that field value behind the scene.

Sample code:
$values["FieldName"] = "some value";

Instead of "some value" you can either use a session variable as @Tandy suggests or you can use Security API.

$values["FieldName"] = Security::getUserName();

More info:
https://xlinesoft.com/phprunner/docs/secapi_get_user_name.htm

S
Simtrain author 2/19/2026

I would like to thank you for the replies, it has solved my problem.

I am not a programmer of any sort, and I'm learning as I go, and having help is really great.

So a big thank you!

Steve