JUser

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
m (bad link repair)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Example ==
+
This class is available in the following Joomla versions:-
This creates a fresh user and save it in the DB.  (It also makes corresponding data for it in acl (access rights etc.)!)
+
<splist showpath=notparent />
 
+
<noinclude>[[Category:Platform JClasses]][[Category:JUser]]</noinclude>
<source lang="php">$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.';
+
</source>
+
MRender is a custom system message Renderer without queue (like JRenderer)
+
 
+
[[Category:Development]]
+

Latest revision as of 14:06, 29 August 2012

This class is available in the following Joomla versions:-

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox