public function signup($params = array()) { # Requirements $this->load(); $this->status['status'] = 'fail'; # Params $user_login = $params['username']; $user_name = $params['name']; $user_email = $params['email']; $user_password = $params['password']; $user_password_2 = $params['password_confirm']; $brought_by = $params['code']; $brought_by = str_replace('#mfr_', '', strtolower($brought_by)); # Validation if (!Session::csrf($params['mariana-csrf'])) { $this->status['errors'] = array(Lang::get('csrf-check-fail')); $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } $inputs = array('username' => array('name' => 'username', 'required' => true, 'alfanum' => true), 'password' => array('name' => 'password', 'required' => true, 'alfanum' => true, 'min' => 3, 'max' => 32), 'password_confirm' => array('name' => 'password_confirm', 'matches' => 'password', 'required' => true), 'email' => array('required' => true, 'email' => true)); if (Validation::check($inputs) === false) { $this->status['errors'] = Framework\Session\Flash::showMessages(); $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } $check_if_username_exists = WpUsers::wp_unique_user($user_login, $user_email); if ($check_if_username_exists) { $this->status['errors'] = $check_if_username_exists; $this->return_json($this->status); return header('HTTP/1.0 200 OK'); } # Create entry on both databases $user_id = wp_create_user($user_login, $user_password, $user_email); MfrUsers::wp_create_user($user_id, $user_name, $brought_by); # Notify wp_new_user_notification($user_id, $user_password); # Sign the user in $params = array(); $params['username'] = $user_login; $params['password'] = $user_password; $this->login($params); $this->return_json($this->status); # Forcing code 200 - Dunno why but keeps failing on this specific function return header('HTTP/1.0 200 OK'); }