我对wordpress比较陌生,现在正在一个定制的网站上工作。
我有一个API端点,我想调用它来进行身份验证,因为我们的用户将由另一个应用程序存储/验证他们的凭据。
对于上下文,API调用如下所示:
$parameters = array(\'email\' => \'email@exampleemail.com\', \'password\' => \'examplepassword\');
$url = \'https://example.com/api/auth?key=123APIkey\' ;
$data = wp_remote_post($url, array(
\'headers\' => array(\'Content-Type\' => \'application/json; charset=utf-8\'),
\'body\' => json_encode($parameters),
\'method\' => \'POST\',
\'data_format\' => \'body\',
));
以下是可能返回的$数据对象的两个示例:
{
"response":200,
"data":{
"email":"sample@someemail.com",
"first_name":"Jane",
"last_name":"Doe",
}
}
或者如果登录失败:
{
"response": 401,
"message": "Unauthorized - Invalid credentials"
}
现在,我已经把这段代码
wp-includes/pluggable.php 在
wp_authenticate($username, $password) 作用但我似乎什么都做不到。如何正确覆盖身份验证功能?
感谢您的帮助,如果需要,请随时询问更多信息!
非常感谢。