所以你的问题是:如何在通过 WP 进行身份验证后创建用户?
我正在考虑您在身份验证过程中没有探针。
如果您使用 PHP,您可以使用 php file_get_contents 函数或 cURL
下面我会给你一个 PHP cURL 的例子
$post = array(
'username' => 'user2',
'email' => 'user2@somedomain.com',
'password' => 'somerandompassword');
$post = http_build_query($post);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/wp/wp-json/wp/v2/users");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "username" . ":" . "password"
);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print_r(json_decode($result, true), true);
如果您的服务器由于某些原因不能使用 cURL,您也可以使用 file_get_contents 函数。您可以在这里找到另一个使用 php 的 WP REST API 示例www.wpsaga.info/tag/wp-rest-api