Using Joomla Profile Plugin
Joomla has made the ability of adding extra user fields very easy with the use of Joomla Profile Plugins. In this tutorial, I will show you how to use the Profile plugin and how to call the fields.
What is a Profile Plugin?
Profile plugin is a new extension in Joomla! 1.6. It allows the addition of supplemental fields in the registration and profile forms of the com_user front end and in the user create/edit form in the back end.
A simple example plugin with the name User – Profile is included in the basic Joomla! installation as a proof of concept. Much more complex plugins are possible.
The example plugin takes advantage of on the onContentPrepareForm and onUserAfterSave events.
Multiple profile plugins may be included and will be rendered in sequence.
There are four separate places where profiles forms are used in core extensions, and each of these four can be manipulated separately if that is desired. The two locations in the front end are the user registration form and the user profile edit form. In the back end the locations are the edit screen for users in the user manager and the My Profile view found in the Admin menu.
This page shows an example of a second plugin, named profile5. It adds a single field called something.
To call profile fields, you simply use the getProfile function from the Joomla User Helper file. JUserHelper::getProfile
public function getProfile ($userId=0)
$new_user_object = JUserHelper::getProfile(111); print_r($new_user_object);
Result would possibly look like the following depending on the user fields you created in your plugin.
Array ( [first_name] => John [last_name] => Doe )
More information coming soon to this tutorial.
Check out this tutorial on creating a Profile Plugin http://docs.joomla.org/Creating_a_profile_plugin