/** * Check if user's email is unique. * @return boolean */ public function beforeValidate() { if (!parent::beforeValidate()) { return false; } if (isset($this->primaryEmail) && isset($this->primaryEmail->emailAddress) && !$this->isUserEmailUnique($this->primaryEmail->emailAddress)) { return false; } return true; }