english/components/com_users/controllers/user.php
/**
	 * Method to register a user.
	 *
	 * @since	1.6
	 */
Method to register a user.
Method to register a user .
public function register()
	{
		JRequest::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
		$data	= JRequest::getVar('user', array(), 'post', 'array');
		$model	= $this->getModel('Registration', 'UsersModel');
		$return	= $model->validate($data);
		if ($return === false) {
			$app	= &JFactory::getApplication();
			$errors	= $model->getErrors();
			for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
				if (JError::isError($errors[$i])) {
					$app->enqueueMessage($errors[$i]->getMessage(), 'notice');
				} else {
					$app->enqueueMessage($errors[$i], 'notice');
				}
			}
			$app->setUserState('users.registration.form.data', $data);
			$this->setRedirect('index.php?option=com_users&view=registration');
			return false;
		}
		$return	= $model->register($data);
		if ($return === false) {
			$app->setUserState('users.registration.form.data', $data);
			$message = JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError());
			$this->setRedirect('index.php?option=com_users&view=registration', $message, 'error');
			return false;
		}
		$app->setUserState('users.registration.form.data', null);
		exit;
	}
public function register ( ) { JRequest :: checkToken ( 'post' ) or jexit ( JText :: _ ( 'JINVALID_TOKEN' ) ) ; $ data = JRequest :: getVar ( 'user' , array ( ) , 'post' , 'array' ) ; $ model = $ this -> getModel ( 'Registration' , 'UsersModel' ) ; $ return = $ model -> validate ( $ data ) ; if ( $ return === false ) { $ app = & JFactory :: getApplication ( ) ; $ errors = $ model -> getErrors ( ) ; for ( $ i = 0 , $ n = count ( $ errors ) ; $ i < $ n && $ i < 3 ; $ i ++ ) { if ( JError :: isError ( $ errors [ $ i ] ) ) { $ app -> enqueueMessage ( $ errors [ $ i ] -> getMessage ( ) , 'notice' ) ; } else { $ app -> enqueueMessage ( $ errors [ $ i ] , 'notice' ) ; } } $ app -> setUserState ( 'users.registration.form.data' , $ data ) ; $ this -> setRedirect ( 'index.php?option=com_users&view=registration' ) ; return false ; } $ return = $ model -> register ( $ data ) ; if ( $ return === false ) { $ app -> setUserState ( 'users.registration.form.data' , $ data ) ; $ message = JText :: sprintf ( 'COM_USERS_REGISTRATION_SAVE_FAILED' , $ model -> getError ( ) ) ; $ this -> setRedirect ( 'index.php?option=com_users&view=registration' , $ message , 'error' ) ; return false ; } $ app -> setUserState ( 'users.registration.form.data' , null ) ; exit ; }
Method to register a user.
Method to register a user .
// Get the form data. // Get the model and validate the data. // Check for errors. // Get the validation messages. // Push up to three validation messages out to the user. // Save the data in the session. // Redirect back to the registration form. // Finish the registration. // Check for errors. // Save the data in the session. // Redirect back to the registration form. // Flush the data from the session.