Actions

Difference between revisions of "Creating a profile plugin"

From Joomla! Documentation

(correction to the code to eliminate default which has unintended consequences.)
(23 intermediate revisions by 13 users not shown)
Line 1: Line 1:
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.
+
{{version/tutor|2.5,3.x}}
 +
Profile plugin is a new extension in Joomla! 2.5. 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 is included in the basic Joomla! installation as a proof of concept. Much more complex plugins are possible.
+
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.  
 
The example plugin takes advantage of on the onContentPrepareForm and onUserAfterSave events.  
  
 
Multiple profile plugins may be included and will be rendered in sequence.
 
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.
 
This page shows an example of a second plugin, named profile5. It adds a single field called something.
Line 11: Line 14:
 
This is the file structure
 
This is the file structure
  
  plugin5.php
+
  profile5.php
  plugin5.xml
+
  profile5.xml
 +
en-GB.plg_user_profile5.ini
 +
en-GB.plg_user_profile5.sys.ini
 
  /profiles/profile.xml
 
  /profiles/profile.xml
  
The supplemental fields are created with xml file in the profiles folder.
+
The supplemental fields are created within the profile.xml file in the profiles folder. Note that this file name is "profile.xml" NOT "profile5.xml", but inside the file the fields and fieldset names ARE "profile5". Note also that the first character in the must be the "<" from the xml tag. Just drop the profile5.xml in a browser tab and if shows you the structure the file is formatted correctly.
  
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="utf-8"?>
 
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: profile.xml 16723 2010-05-04 01:37:00Z eddieajau $ -->
+
 
<form>
 
<form>
<fields name="profile">
+
<fields name="profile5">
<fieldset name="profile"
+
<fieldset name="profile5"
label="PLG_USER_PROFILE_SLIDER_LABEL"
+
label="PLG_USER_PROFILE5_SLIDER_LABEL"
 
>
 
>
 
<field
 
<field
Line 29: Line 34:
 
type="text"
 
type="text"
 
id="something"
 
id="something"
description="PLG_USER_PROFILE_FIELD_SOMETHING_DESC"
+
description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
 
filter="string"
 
filter="string"
label="PLG_USER_PROFILE_FIELD_SOMETHING_LABEL"
+
label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
message="PLG_USER_PROFILE_FIELD_SOMETHING_MESSAGE"
+
message="PLG_USER_PROFILE5_FIELD_SOMETHING_MESSAGE"
 
size="30"
 
size="30"
 
/>
 
/>
Line 48: Line 53:
 
  <?php
 
  <?php
 
  /**
 
  /**
   * @version $Id: profile.php 17685 2010-06-14 21:46:46Z dextercowley $
+
   * @version
 
   * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 
   * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 
   * @license GNU General Public License version 2 or later; see LICENSE.txt
 
   * @license GNU General Public License version 2 or later; see LICENSE.txt
Line 74: Line 79:
 
{
 
{
 
// Check we are manipulating a valid form.
 
// Check we are manipulating a valid form.
if (!in_array($context, array('com_users.profile', 'com_users.registration'))) {
+
if (!in_array($context, array('com_users.profile','com_users.registration','com_users.user','com_admin.profile'))){
 
return true;
 
return true;
 
}
 
}
Line 81: Line 86:
  
 
// Load the profile data from the database.
 
// Load the profile data from the database.
$db = &JFactory::getDbo();
+
$db = JFactory::getDbo();
 
$db->setQuery(
 
$db->setQuery(
 
'SELECT profile_key, profile_value FROM #__user_profiles' .
 
'SELECT profile_key, profile_value FROM #__user_profiles' .
 
' WHERE user_id = '.(int) $userId .
 
' WHERE user_id = '.(int) $userId .
 +
' AND profile_key LIKE \'profile5.%\'' .
 
' ORDER BY ordering'
 
' ORDER BY ordering'
 
);
 
);
Line 96: Line 102:
  
 
// Merge the profile data.
 
// Merge the profile data.
$data->profile = array();
+
$data->profile5 = array();
 
foreach ($results as $v) {
 
foreach ($results as $v) {
$k = str_replace('profile.', '', $v[0]);
+
$k = str_replace('profile5.', '', $v[0]);
$data->profile[$k] = $v[1];
+
$data->profile5[$k] = json_decode($v[1], true);
 
}
 
}
  
Line 115: Line 121:
 
// Load user_profile plugin language
 
// Load user_profile plugin language
 
$lang = JFactory::getLanguage();
 
$lang = JFactory::getLanguage();
$lang->load('plg_user_profile', JPATH_ADMINISTRATOR);
+
$lang->load('plg_user_profile5', JPATH_ADMINISTRATOR);
  
 
if (!($form instanceof JForm)) {
 
if (!($form instanceof JForm)) {
Line 122: Line 128:
 
}
 
}
 
// Check we are manipulating a valid form.
 
// Check we are manipulating a valid form.
if (!in_array($form->getName(), array('com_users.profile', 'com_users.registration','com_users.user'))) {
+
if (!in_array($form->getName(), array('com_users.profile', 'com_users.registration','com_users.user','com_admin.profile'))) {
 
return true;
 
return true;
 
}
 
}
Line 133: Line 139:
 
// Toggle whether the something field is required.
 
// Toggle whether the something field is required.
 
if ($this->params->get('profile-require_something', 1) > 0) {
 
if ($this->params->get('profile-require_something', 1) > 0) {
$form->setFieldAttribute('something', 'required', $this->params->get('profile-require_something') == 2, 'profile');
+
$form->setFieldAttribute('something', 'required', $this->params->get('profile-require_something') == 2, 'profile5');
 
} else {
 
} else {
$form->removeField('something', 'profile');
+
$form->removeField('something', 'profile5');
 
}
 
}
+
}
 +
 
 
//In this example, we treat the frontend registration and the back end user create or edit as the same.  
 
//In this example, we treat the frontend registration and the back end user create or edit as the same.  
 
elseif ($form->getName()=='com_users.registration' || $form->getName()=='com_users.user' )
 
elseif ($form->getName()=='com_users.registration' || $form->getName()=='com_users.user' )
Line 147: Line 154:
 
// Toggle whether the something field is required.
 
// Toggle whether the something field is required.
 
if ($this->params->get('register-require_something', 1) > 0) {
 
if ($this->params->get('register-require_something', 1) > 0) {
$form->setFieldAttribute('something', 'required', $this->params->get('register-require_something') == 2, 'profile');
+
$form->setFieldAttribute('something', 'required', $this->params->get('register-require_something') == 2, 'profile5');
 
} else {
 
} else {
$form->removeField('something', 'profile');
+
$form->removeField('something', 'profile5');
 
}
 
}
 
}
 
}
Line 158: Line 165:
 
$userId = JArrayHelper::getValue($data, 'id', 0, 'int');
 
$userId = JArrayHelper::getValue($data, 'id', 0, 'int');
  
if ($userId && $result && isset($data['profile']) && (count($data['profile'])))
+
if ($userId && $result && isset($data['profile5']) && (count($data['profile5'])))
 
{
 
{
 
try
 
try
 
{
 
{
$db = &JFactory::getDbo();
+
$db = JFactory::getDbo();
$db->setQuery('DELETE FROM #__user_profiles WHERE user_id = '.$userId);
+
$db->setQuery('DELETE FROM #__user_profiles WHERE user_id = '.$userId.' AND profile_key LIKE \'profile5.%\'');
 
if (!$db->query()) {
 
if (!$db->query()) {
 
throw new Exception($db->getErrorMsg());
 
throw new Exception($db->getErrorMsg());
Line 170: Line 177:
 
$tuples = array();
 
$tuples = array();
 
$order = 1;
 
$order = 1;
foreach ($data['profile'] as $k => $v) {
+
foreach ($data['profile5'] as $k => $v) {
$tuples[] = '('.$userId.', '.$db->quote('profile.'.$k).', '.$db->quote($v).', '.$order++.')';
+
$tuples[] = '('.$userId.', '.$db->quote('profile5.'.$k).', '.$db->quote(json_encode($v)).', '.$order++.')';
 
}
 
}
  
Line 187: Line 194:
 
return true;
 
return true;
 
}
 
}
 +
 +
/**
 +
* Remove all user profile information for the given user ID
 +
*
 +
* Method is called after user data is deleted from the database
 +
*
 +
* @param array $user Holds the user data
 +
* @param boolean $success True if user was succesfully stored in the database
 +
* @param string $msg Message
 +
*/
 +
function onUserAfterDelete($user, $success, $msg)
 +
{
 +
if (!$success) {
 +
return false;
 +
}
 +
 +
$userId = JArrayHelper::getValue($user, 'id', 0, 'int');
 +
 +
if ($userId)
 +
{
 +
try
 +
{
 +
$db = JFactory::getDbo();
 +
$db->setQuery(
 +
'DELETE FROM #__user_profiles WHERE user_id = '.$userId .
 +
" AND profile_key LIKE 'profile5.%'"
 +
);
 +
 +
if (!$db->query()) {
 +
throw new Exception($db->getErrorMsg());
 +
}
 +
}
 +
catch (JException $e)
 +
{
 +
$this->_subject->setError($e->getMessage());
 +
return false;
 +
}
 +
}
 +
 +
return true;
 +
}
 +
 +
 
  }
 
  }
 +
 
</source>
 
</source>
  
  
Profile5.xml controls whether the field is required, disabled or optional in the forms. Since profile5.php says to treat backend create/edit the same as registration only two sets of options are required, register and profile.
+
profile5.xml controls whether the field is required, disabled or optional in the forms. Since profile5.php says to treat backend create/edit the same as registration only two sets of options are required, register and profile. Note: First character of the file must be "<". Just drop the profile5.xml in a browser tab and if shows you the structure the file is formatted correctly.
  
 
<source lang="xml">
 
<source lang="xml">
 
  <?xml version="1.0" encoding="utf-8"?>
 
  <?xml version="1.0" encoding="utf-8"?>
 
<!-- $Id:  -->
 
<!-- $Id:  -->
<install version="1.6" type="plugin" group="user">
+
<extension version="3.1" type="plugin" group="user">
 
<name>plg_user_profile5</name>
 
<name>plg_user_profile5</name>
 
<author>Joomla! Project</author>
 
<author>Joomla! Project</author>
 
<creationDate>January 2008</creationDate>
 
<creationDate>January 2008</creationDate>
<copyright>(C) 2005 - 2010 Open Source Matters. All rights reserved.</copyright>
+
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
 
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
 
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
 
<authorEmail>admin@joomla.org</authorEmail>
 
<authorEmail>admin@joomla.org</authorEmail>
 
<authorUrl>www.joomla.org</authorUrl>
 
<authorUrl>www.joomla.org</authorUrl>
<version>1.6.0</version>
+
<version>3.0.0</version>
<description>PLG_USER_PROFILE_XML_DESCRIPTION</description>
+
<description>PLG_USER_PROFILE5_XML_DESCRIPTION</description>
  
 
<files>
 
<files>
Line 214: Line 265:
  
 
<languages>
 
<languages>
<language tag="en-GB">en-GB.plg_user_profile.ini</language>
+
<language tag="en-GB">en-GB.plg_user_profile5.ini</language>
<language tag="en-GB">en-GB.plg_user_profile.sys.ini</language>
+
<language tag="en-GB">en-GB.plg_user_profile5.sys.ini</language>
 
</languages>
 
</languages>
  
Line 223: Line 274:
 
<fieldset name="basic">
 
<fieldset name="basic">
 
<field name="register-require-user" type="spacer"
 
<field name="register-require-user" type="spacer"
label="PLG_USER_PROFILE_FIELD_NAME_REGISTER_REQUIRE_USER"
+
label="PLG_USER_PROFILE5_FIELD_NAME_REGISTER_REQUIRE_USER"
 
/>
 
/>
  
 
<field name="register-something" type="list"
 
<field name="register-something" type="list"
description="PLG_USER_PROFILE_FIELD_SOMETHING_DESC"
+
description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
label="PLG_USER_PROFILE_FIELD_ADDRESS1_LABEL"
+
label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
 
>
 
>
 
<option value="2">JOPTION_REQUIRED</option>
 
<option value="2">JOPTION_REQUIRED</option>
Line 236: Line 287:
  
 
<field name="profile-require-user" type="spacer"
 
<field name="profile-require-user" type="spacer"
label="PLG_USER_PROFILE_FIELD_NAME_PROFILE_REQUIRE_USER"
+
label="PLG_USER_PROFILE5_FIELD_NAME_PROFILE_REQUIRE_USER"
 
/>
 
/>
  
 
<field name="profile-require_something" type="list"
 
<field name="profile-require_something" type="list"
description="PLG_USER_PROFILE_FIELD_SOMETHING_DESC"
+
description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
label="PLG_USER_PROFILE_FIELD_SOMETHING_LABEL"
+
label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
 
>
 
>
 
<option value="2">JOPTION_REQUIRED</option>
 
<option value="2">JOPTION_REQUIRED</option>
Line 252: Line 303:
 
</fields>
 
</fields>
 
</config>
 
</config>
  </install>
+
  </extension>
 
  </source>
 
  </source>
 +
 +
en-GB.plg_user_profile5.ini
 +
 +
;
 +
; Joomla! Project
 +
; Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
 +
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
 +
; Note : All ini files need to be saved as UTF-8
 +
 +
PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"
 +
PLG_USER_PROFILE5="User - Profile 5"
 +
PLG_USER_PROFILE5_SLIDER_LABEL="User Profile 5"
 +
PLG_USER_PROFILE5_FIELD_NAME_REGISTER_REQUIRE_USER="User profile fields for registration and administrator user profile 5 forms"
 +
PLG_USER_PROFILE5_FIELD_NAME_PROFILE_REQUIRE_USER="User profile fields for profile 5 edit form"
 +
PLG_USER_PROFILE5_FIELD_SOMETHING_DESC="Choose an option for the something filed"
 +
PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL="Something!"
 +
PLG_USER_PROFILE5_FIELD_SOMETHING_MESSAGE="A Message for something!"
 +
PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"
 +
 +
en-GB.plg_user_profile5.sys.ini
 +
 +
; $Id: en-GB.plg_user_profile.sys.ini 17052 2010-05-14 14:05:58Z infograf768 $
 +
; Joomla! Project
 +
; Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
 +
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
 +
; Note : All ini files need to be saved as UTF-8
 +
 +
PLG_USER_PROFILE5="User - Profile 5 "
 +
PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"
  
 
By installing profile5 you can add new fields in addition to the ones in profile. You can also control which view levels see those fields.
 
By installing profile5 you can add new fields in addition to the ones in profile. You can also control which view levels see those fields.

Revision as of 09:29, 31 October 2013

Profile plugin is a new extension in Joomla! 2.5. 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.

This is the file structure

profile5.php
profile5.xml
en-GB.plg_user_profile5.ini
en-GB.plg_user_profile5.sys.ini
/profiles/profile.xml

The supplemental fields are created within the profile.xml file in the profiles folder. Note that this file name is "profile.xml" NOT "profile5.xml", but inside the file the fields and fieldset names ARE "profile5". Note also that the first character in the must be the "<" from the xml tag. Just drop the profile5.xml in a browser tab and if shows you the structure the file is formatted correctly.

<?xml version="1.0" encoding="utf-8"?>
 
<form>
        <fields name="profile5">
                <fieldset name="profile5"
                        label="PLG_USER_PROFILE5_SLIDER_LABEL"
                >
                        <field
                                name="something"
                                type="text"
                                id="something"
                                description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
                                filter="string"
                                label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
                                message="PLG_USER_PROFILE5_FIELD_SOMETHING_MESSAGE"
                                size="30"
                        />
 
 
                </fieldset>
        </fields>
</form>


profile5.php

 <?php
 /**
  * @version            
  * @copyright  Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  * @license            GNU General Public License version 2 or later; see LICENSE.txt
  */
 
 defined('JPATH_BASE') or die;
 
  /**
   * An example custom profile plugin.
   *
   * @package           Joomla.Plugins
   * @subpackage        user.profile
   * @version           1.6
   */
  class plgUserProfile5 extends JPlugin
  {
        /**
         * @param       string  The context for the data
         * @param       int             The user id
         * @param       object
         * @return      boolean
         * @since       1.6
         */
        function onContentPrepareData($context, $data)
        {
                // Check we are manipulating a valid form.
                if (!in_array($context, array('com_users.profile','com_users.registration','com_users.user','com_admin.profile'))){
                        return true;
                }
 
                $userId = isset($data->id) ? $data->id : 0;
 
                // Load the profile data from the database.
                $db = JFactory::getDbo();
                $db->setQuery(
                        'SELECT profile_key, profile_value FROM #__user_profiles' .
                        ' WHERE user_id = '.(int) $userId .
                        ' AND profile_key LIKE \'profile5.%\'' .
                        ' ORDER BY ordering'
                );
                $results = $db->loadRowList();
 
                // Check for a database error.
                if ($db->getErrorNum()) {
                        $this->_subject->setError($db->getErrorMsg());
                        return false;
                }
 
                // Merge the profile data.
                $data->profile5 = array();
                foreach ($results as $v) {
                        $k = str_replace('profile5.', '', $v[0]);
                        $data->profile5[$k] = json_decode($v[1], true);
                }
 
                return true;
        }
 
        /**
         * @param       JForm   The form to be altered.
         * @param       array   The associated data for the form.
         * @return      boolean
         * @since       1.6
         */
        function onContentPrepareForm($form, $data)
        {
                // Load user_profile plugin language
                $lang = JFactory::getLanguage();
                $lang->load('plg_user_profile5', JPATH_ADMINISTRATOR);
 
                if (!($form instanceof JForm)) {
                        $this->_subject->setError('JERROR_NOT_A_FORM');
                        return false;
                }
                // Check we are manipulating a valid form.
                if (!in_array($form->getName(), array('com_users.profile', 'com_users.registration','com_users.user','com_admin.profile'))) {
                        return true;
                }
                if ($form->getName()=='com_users.profile')
                {
                        // Add the profile fields to the form.
                        JForm::addFormPath(dirname(__FILE__).'/profiles');
                        $form->loadFile('profile', false);
 
                        // Toggle whether the something field is required.
                        if ($this->params->get('profile-require_something', 1) > 0) {
                                $form->setFieldAttribute('something', 'required', $this->params->get('profile-require_something') == 2, 'profile5');
                        } else {
                                $form->removeField('something', 'profile5');
                        }
                }
 
                //In this example, we treat the frontend registration and the back end user create or edit as the same. 
                elseif ($form->getName()=='com_users.registration' || $form->getName()=='com_users.user' )
                {               
                        // Add the registration fields to the form.
                        JForm::addFormPath(dirname(__FILE__).'/profiles');
                        $form->loadFile('profile', false);
 
                        // Toggle whether the something field is required.
                        if ($this->params->get('register-require_something', 1) > 0) {
                                $form->setFieldAttribute('something', 'required', $this->params->get('register-require_something') == 2, 'profile5');
                        } else {
                                $form->removeField('something', 'profile5');
                        }
                }                       
        }
 
        function onUserAfterSave($data, $isNew, $result, $error)
        {
                $userId = JArrayHelper::getValue($data, 'id', 0, 'int');
 
                if ($userId && $result && isset($data['profile5']) && (count($data['profile5'])))
                {
                        try
                        {
                                $db = JFactory::getDbo();
                                $db->setQuery('DELETE FROM #__user_profiles WHERE user_id = '.$userId.' AND profile_key LIKE \'profile5.%\'');
                                if (!$db->query()) {
                                        throw new Exception($db->getErrorMsg());
                                }
 
                                $tuples = array();
                                $order  = 1;
                                foreach ($data['profile5'] as $k => $v) {
                                        $tuples[] = '('.$userId.', '.$db->quote('profile5.'.$k).', '.$db->quote(json_encode($v)).', '.$order++.')';
                                }
 
                                $db->setQuery('INSERT INTO #__user_profiles VALUES '.implode(', ', $tuples));
                                if (!$db->query()) {
                                        throw new Exception($db->getErrorMsg());
                                }
                        }
                        catch (JException $e) {
                                $this->_subject->setError($e->getMessage());
                                return false;
                        }
                }
 
                return true;
        }
 
        /**
         * Remove all user profile information for the given user ID
         *
         * Method is called after user data is deleted from the database
         *
         * @param       array           $user           Holds the user data
         * @param       boolean         $success        True if user was succesfully stored in the database
         * @param       string          $msg            Message
         */
        function onUserAfterDelete($user, $success, $msg)
        {
                if (!$success) {
                        return false;
                }
 
                $userId = JArrayHelper::getValue($user, 'id', 0, 'int');
 
                if ($userId)
                {
                        try
                        {
                                $db = JFactory::getDbo();
                                $db->setQuery(
                                        'DELETE FROM #__user_profiles WHERE user_id = '.$userId .
                                        " AND profile_key LIKE 'profile5.%'"
                                );
 
                                if (!$db->query()) {
                                        throw new Exception($db->getErrorMsg());
                                }
                        }
                        catch (JException $e)
                        {
                                $this->_subject->setError($e->getMessage());
                                return false;
                        }
                }
 
                return true;
        }
 
 
 }


profile5.xml controls whether the field is required, disabled or optional in the forms. Since profile5.php says to treat backend create/edit the same as registration only two sets of options are required, register and profile. Note: First character of the file must be "<". Just drop the profile5.xml in a browser tab and if shows you the structure the file is formatted correctly.

 <?xml version="1.0" encoding="utf-8"?>
        <!-- $Id:  -->
<extension version="3.1" type="plugin" group="user">
        <name>plg_user_profile5</name>
        <author>Joomla! Project</author>
        <creationDate>January 2008</creationDate>
        <copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
        <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
        <authorEmail>admin@joomla.org</authorEmail>
        <authorUrl>www.joomla.org</authorUrl>
        <version>3.0.0</version>
        <description>PLG_USER_PROFILE5_XML_DESCRIPTION</description>
 
        <files>
                <filename plugin="profile5">profile5.php</filename>
                <filename>index.html</filename>
                <folder>profiles</folder>
        </files>
 
        <languages>
                <language tag="en-GB">en-GB.plg_user_profile5.ini</language>
                <language tag="en-GB">en-GB.plg_user_profile5.sys.ini</language>
        </languages>
 
        <config>
                <fields name="params">
 
                        <fieldset name="basic">
                                <field name="register-require-user" type="spacer"
                                        label="PLG_USER_PROFILE5_FIELD_NAME_REGISTER_REQUIRE_USER"
                                />
 
                                <field name="register-something" type="list"
                                        description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
                                        label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
                                >
                                        <option value="2">JOPTION_REQUIRED</option>
                                        <option value="1">JOPTION_OPTIONAL</option>
                                        <option value="0">JDISABLED</option>
                                </field>
 
                                <field name="profile-require-user" type="spacer"
                                        label="PLG_USER_PROFILE5_FIELD_NAME_PROFILE_REQUIRE_USER"
                                />
 
                                <field name="profile-require_something" type="list"
                                        description="PLG_USER_PROFILE5_FIELD_SOMETHING_DESC"
                                        label="PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL"
                                >
                                        <option value="2">JOPTION_REQUIRED</option>
                                        <option value="1">JOPTION_OPTIONAL</option>
                                        <option value="0">JDISABLED</option>
                                </field>
 
                        </fieldset>
 
                </fields>
        </config>
 </extension>

en-GB.plg_user_profile5.ini

; 
; Joomla! Project
; Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"
PLG_USER_PROFILE5="User - Profile 5"
PLG_USER_PROFILE5_SLIDER_LABEL="User Profile 5"
PLG_USER_PROFILE5_FIELD_NAME_REGISTER_REQUIRE_USER="User profile fields for registration and administrator user profile 5 forms"
PLG_USER_PROFILE5_FIELD_NAME_PROFILE_REQUIRE_USER="User profile fields for profile 5 edit form"
PLG_USER_PROFILE5_FIELD_SOMETHING_DESC="Choose an option for the something filed"
PLG_USER_PROFILE5_FIELD_SOMETHING_LABEL="Something!"
PLG_USER_PROFILE5_FIELD_SOMETHING_MESSAGE="A Message for something!"
PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"

en-GB.plg_user_profile5.sys.ini

; $Id: en-GB.plg_user_profile.sys.ini 17052 2010-05-14 14:05:58Z infograf768 $
; Joomla! Project
; Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_USER_PROFILE5="User - Profile 5 "
PLG_USER_PROFILE5_XML_DESCRIPTION="User Profile 5 Plug-in"

By installing profile5 you can add new fields in addition to the ones in profile. You can also control which view levels see those fields. Alternatively, you can write a more complex common plugin with varying controls for different groups.