1

I am developing a job site for a client where he needs to be able to have his user registered either as an "Employer" or as a "Job Seeker". As with the new Joomla we do have different Access levels i want users to be able to Select the Usergroup through a dropdown field while registration.

While i was working on it i found out that you can have custom fields added to the form. So i added the following code to "/joomla/components/com_users/models/forms/registration.xml"

<field
    name="usertype"
    type="groups"
    id="usertype"
/>

fieldtype "groups" is a joomla defined field type under "/joomla/libraries/joomla/form/fields/"

But the problem is it shows up as a dropdown with all the user groups including "Administrator" and "Super Users".

however i would like it to show only the Custom Added user groups which are "Employer" & "Jobseeker"

Following is some information that might be required: Joomla version : 1.6 PHP Version : 5.3 Apache Server: 2.2.11

Code to the Field "Groups":

protected function _getOptions()
{
    // Get a database object.
    $db = &JFactory::getDbo();

    // Get the user groups from the database.
    $db->setQuery(
        'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' .
        ' FROM #__usergroups AS a' .
        ' LEFT JOIN `#__usergroups` AS b ON a.lft > b.lft AND a.rgt < b.rgt' .
        ' GROUP BY a.id' .
        ' ORDER BY a.lft ASC'
    );
    $options = $db->loadObjectList();

    // Pad the option text with spaces using depth level as a multiplier.
    for ($i=0,$n=count($options); $i < $n; $i++) {
        $options[$i]->text = str_repeat('- ',$options[$i]->level).$options[$i]->text;
    }

    // Merge any additional options in the XML definition.
    //$options = array_merge(parent::_getOptions(), $options);

    return $options;
}

I also tried editing the above field by adding

'WHERE id >=10'

But then dropdown loads with no options. and yes the ID's in Mysql tables for the custom groups are 10 and 11.

Could anyone help with a quick work around or a solution on this. Your Time and help is much Appreciated. Thanks

--Rusty--

ghostJago
  • 3,381
  • 5
  • 36
  • 51
RustyRyan
  • 11
  • 3

0 Answers0