Page 1 of 1

autopopulate column based on who's logged in? [SOLVED]

PostPosted: Wed Sep 01, 2010 4:14 am
by cantlep
Hi There,

is there anyway to automatically populate a field (i.e. a Username field) with the name of the user that's currently logged in?

What I'm after is that when a user logs in and creates a new record. Their username is auto added to a field (which I'll hide later on).

Thanks

Paul

Re: autopopulate column based on who's logged in?

PostPosted: Wed Sep 01, 2010 7:01 am
by cantlep
Sorted:

Found some old posts which helped:


Code: Select all
function beforeInsert(&$record){
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUsername();
    //$record->setValue('UserName', $user->val('UserName'));
    $record->SetValue('UserName', $user);
}

Did the trick :-)