Skip to content

How to include a user's ID "behind the scenes" during edit?

Problem:
If whenever a record is added to the database I want to include a user's ID behind the scenes. In other words I have the userid in a variable from when they logged into the system.

Solution: 
If the user id is known during editing, you can simply set its value using set column default function.

$dg -> set_col_default('MyUserId', $_SESSION['UserID']);

You can choose to hide this field from editing using simple CSS. For example, when the field name is 'myuserid', you can hide the field from editing form, and still get saved.

When the value is not available until after edit, the approach is to use the event handler 


Feedback and Knowledge Base