在joomla 1.5中为新用户分配gid


Assigning gid to new user in joomla 1.5

我在注册用户下创建了几个新的子组,当我从后端创建新用户时,一切都很好。当试图在前端创建帐户时,系统会向他们提供父组(注册用户)的gid。我想知道你是否能把gid传给joomla。这是我正在使用的不起作用的脚本。非常感谢!

           // Begin create user
            global $mainframe;
            JFactory::getLanguage()->load('com_user');
            $this->execPieceByName('ff_InitLib');
    $user       = clone(JFactory::getUser());
    $pathway    =& $mainframe->getPathway();
    $config     =& JFactory::getConfig();
    $authorize  =& JFactory::getACL();
    $document   =& JFactory::getDocument();
    // If user registration is not allowed, show 403 not authorized.
    $usersConfig = &JComponentHelper::getParams( 'com_users' );
    if ($usersConfig->get('allowUserRegistration') == '0') {
        echo '<script>alert("Access forbidden");history.go(-1);</script>';
        return;
    } else {
        // Initialize new usertype setting
        $newUsertype = $usersConfig->get( 'new_usertype' );
        if (!$newUsertype) {
            $newUsertype = 'Free User';
        }
        // Bind the post array to the user object
        $post = array(
            'name' => ff_getSubmit('ownerName'), 
            'username' => ff_getSubmit('ownerEmail'), 
            'email' => ff_getSubmit('ownerEmail'), 
            'password' => ff_getSubmit('password'), 
            'password2' => ff_getSubmit('password'), 
            'task' => 'register_save',
            'id' => '0',
            'gid' => ff_getSubmit('101'),
            );
        if (!$user->bind( $post, 'usertype' )) {
            echo '<script>alert("'.addslashes($user-      >getError()).'");history.go(-1);</script>';
            return;
        } else {
            // Set some initial user values
            $user->set('id', 0);
            $user->set('usertype', 'Free User');
            $user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
            $date =& JFactory::getDate();
            $user->set('registerDate', $date->toMySQL());
            // If user activation is turned on, we need to set the activation information
            $useractivation = $usersConfig->get( 'useractivation' );
            if ($useractivation == '1')
            {
                jimport('joomla.user.helper');
                $user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) );
                $user->set('block', '1');
            }
            // If there was an error with registration, set the message and display form
            if ( !$user->save() )
            {
                echo '<script>alert("'.addslashes(JText::_( $user->getError())).'");history.go(-1);</script>';
                return;
            } else {
                $db     =& JFactory::getDBO();
                $name       = $user->get('name');
                $email      = $user->get('email');
                $username   = $user->get('username');
                JFactory::getDBO()->setQuery("Update #__facileforms_records Set user_id = '".$user->get('id')."', 

username=".JFactory::getDBO()->Quote($username)。",user_full_name=".肯尼迪工厂::getDB奥()->报价($name)。"其中id='".$this->record_id."'");JFactory::getDBO()->query();}

        }
    }

[SOLVED]在joomla 1.5 中为新用户分配gid

我想明白了。如果有其他人在寻找这个问题的答案,只需替换这行代码:

$user->set('gid',$authorize->get_group_id('',$newUsertype,'ARO'));

带有

$user->set('gid','your-gid#);