JUser
From Joomla! Documentation
(Difference between revisions)
(gid & usertype) |
|||
| Line 1: | Line 1: | ||
| − | This creates a fresh user and save it in the DB. (It also makes | + | This creates a fresh user and save it in the DB. (It also makes corresponding data for it in acl (access rights etc.)!) |
<source lang="php">$NU = new JUser(); | <source lang="php">$NU = new JUser(); | ||
| Line 8: | Line 8: | ||
$NU->gid = 29; | $NU->gid = 29; | ||
$NU->usertype='Public Frontend'; | $NU->usertype='Public Frontend'; | ||
| + | //JUserTable::check() is implicitly done here! | ||
if (!$NU->save(false)) { MRender('Error: User not saved!!<br/>'.$NU->getError());return; } | if (!$NU->save(false)) { MRender('Error: User not saved!!<br/>'.$NU->getError());return; } | ||
| − | else $MR[]=' | + | else $MR[]='Success.'; |
</source> | </source> | ||
MRender is a custom system message Renderer without queue (like JRenderer) | MRender is a custom system message Renderer without queue (like JRenderer) | ||
Revision as of 13:12, 2 April 2008
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)