Adding logged on user to a record
Archived from the Xataface Users forum.
ngms27 — Thu Jan 10, 2013 7:41 am
I have a table Projects which has a 1 to many relationship with Notes.
I’d like to be able to add the logged on user to a field in Notes every time a new notes record is added.
i.e. Notes structure is currently
id
project_id
details
I’d change it to
id
project_id
details
user
shannah — Thu Jan 10, 2013 10:27 am
Use beforeSave() or beforeInsert().
- Code: Select all
function beforeSave(Dataface_Record $record){ $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName(); $record->setValue('user', $username); }
ngms27 — Fri Jan 11, 2013 6:19 am
Worked great thank you.