/** * Creating new user * @param String $name User full name * @param String $email User login email id * @param String $password User login password */ public function createUser(CustomParseUser $cpu) { $response = array(); // First check if user already existed in db if (!$this->isUserExists($cpu->getUserName(), $cpu->getEmail())) { // Generating API key $api_key = $this->generateApiKey($cpu->getEmail()); $user = new ParseUser(); $user->set("username", $cpu->getUsername()); $user->set("password", $cpu->getPassword()); $user->set("email", $cpu->getEmail()); $user->set("firstName", $cpu->getFirstName()); $user->set("lastName", $cpu->getLastName()); $user->set("birthday", $cpu->getBirthday()); $user->set("apiKey", $api_key); try { $user->signUp(); // Hooray! Let them use the app now. return 'USER_CREATED_SUCCESSFULLY'; } catch (Parse\ParseException $ex) { // Show the error message somewhere and let the user try again. echo "Error: " . $ex->getCode() . " " . $ex->getMessage(); return 'USER_CREATE_FAILED'; } } else { // User with same email already existed in the db return 'USER_ALREADY_EXISTED'; } return $response; }