JUser example

Jump to: navigation, search


This creates a fresh user and save it in the DB. (It also makes corresponding data for it in acl (access rights etc.)!)

$NU = new JUser();
$NU->name = $P['firstname'].' '.$P['lastname'];
$NU->username = $P['username'];
$NU->email = $P['email'];
//NEVER forget the following 2, otherwise the user may never be visible. Why isn't this automated?
$NU->gid = 29;
$NU->usertype='Public Frontend';
//JUserTable::check() is implicitly done here!
if (!$NU->save(false))	{	MRender('Error: User not saved!!<br/>'.$NU->getError());return;		}
else $MR[]='Success.';

MRender is a custom system message Renderer without queue (like JRenderer)

Personal tools