src/Model/Behavior/UserBehavior.php
public function register(EntityInterface $entity, $options = []) {
		$options = array_merge($this->_config['register'], $options);

		if ($options['beforeRegister'] === true) {
			$entity = $this->_beforeRegister($entity, $options);
		}

		$event = $this->dispatchEvent('User.beforeRegister', [
			'data' => $entity,
			'table' => $this->_table
		]);

		if ($event->isStopped()) {
			return $event->result;
		}

		$result = $this->_table->save($entity, $options['saveOptions']);

		if (!$result) {
			return $result;
		}

		if ($options['afterRegister'] === true) {
			$this->_afterRegister($result, $options);
		}

		$event = $this->dispatchEvent('user.afterRegister', [
			'data' => $result,
			'table' => $this->_table
		]);

		if ($event->isStopped()) {
			return $event->result;
		}

		return $result;
	}
public function register(EntityInterface $entity, $options = []) {
		$options = array_merge($this->_config['register'], $options);

		if ($options['beforeRegister'] === true) {
			$entity = $this->_beforeRegister($entity, $options);
		}

		$event = $this->dispatchEvent('User.beforeRegister', [
			'data' => $entity,
			'table' => $this->_table
		]);

		if ($event->isStopped()) {
			return $event->result;
		}

		$result = $this->_table->save($entity, $options['saveOptions']);

		if (!$result) {
			return $result;
		}

		if ($options['afterRegister'] === true) {
			$this->_afterRegister($result, $options);
		}

		$event = $this->dispatchEvent('user.afterRegister', [
			'data' => $result,
			'table' => $this->_table
		]);

		if ($event->isStopped()) {
			return $event->result;
		}

		return $result;
	}
public function register ( EntityInterface $ entity , $ options = [ ] ) { $ options = array_merge ( $ this -> _config [ 'register' ] , $ options ) ; if ( $ options [ 'beforeRegister' ] === true ) { $ entity = $ this -> _beforeRegister ( $ entity , $ options ) ; } $ event = $ this -> dispatchEvent ( 'User.beforeRegister' , [ 'data' => $ entity , 'table' => $ this -> _table ] ) ; if ( $ event -> isStopped ( ) ) { return $ event -> result ; } $ result = $ this -> _table -> save ( $ entity , $ options [ 'saveOptions' ] ) ; if ( ! $ result ) { return $ result ; } if ( $ options [ 'afterRegister' ] === true ) { $ this -> _afterRegister ( $ result , $ options ) ; } $ event = $ this -> dispatchEvent ( 'user.afterRegister' , [ 'data' => $ result , 'table' => $ this -> _table ] ) ; if ( $ event -> isStopped ( ) ) { return $ event -> result ; } return $ result ; }
Registers a new user

You can modify the registration process through implementing an event
listener for the User.beforeRegister and User.afterRegister events.

If you stop the events the result of the event will be returned.

Flow:
- calls the behaviors _beforeRegister method if not disabled via config
- Fires the User.beforeRegister event
- Attempt to save the user data
- calls the behaviors _afterRegister method if not disabled via config
- Fires the User.afterRegister event

Options:
- `beforeRegister` - Bool to call the internal _beforeRegister() method.
Default is true
- `afterRegister` - Bool to call the internal _beforeRegister() method.
Default is true
- `tokenLength` - Length of the verification token, default is 32
- `saveOptions` Optional save options to be passed to the save() call.
- `verificationExpirationTime` - Default is `+1 day`
- `emailVerification` - Use email verification or not, default is true.
- `defaultRole` - Default role to set in the mapped `role` field.
- `userActive` - Set the user to active by default on registration.
Default is true
- `generatePassword` - To generate a password or not. Default is false.
- `hashPassword` - To has the password or not, default is true.

@param \Cake\Datasource\EntityInterface $entity User Entity
@param array $options Options
@throws \InvalidArgumentException
@return \Cake\Datasource\EntityInterface|bool Returns bool false if the user could not be saved.
Registers a new user