/** * Create a new user. * * @param $data * @return mixed */ public function create_user($data) { $status = true; if (!current_user_can('create_users')) { json_error(BigAppErr::$user['code'], BigAppErr::$user['msg'], "Sorry, you are not allowed to create users.."); } if (!empty($data['ID'])) { json_error(BigAppErr::$user['code'], BigAppErr::$user['msg'], "Cannot create existing user.."); } $user_id = $this->insert_user($data); if (is_wp_error($user_id)) { $status = false; } $response = $this->get_user($user_id); if (!$response instanceof WP_JSON_ResponseInterface) { $response = new WP_JSON_Response($response); } $response->set($status); return $response; }