PHP文件包含Wordpress文件Include。
Ajax调用是:
$(function () {
$("#autorizacion").submit(function () {
datos = $(this).serialize()
$.ajax({
type: "GET",
url: "http://somesite.com/authorization.php",
dataType: "HTML",
data: datos,
beforeSend: function () {
alert(datos);
},
error: function (xhr, status, error) {
alert(error);
},
success: function (res) {
alert(res);
}
})
return false;
})
})
PHP文件包含:
header("HTTP/1.1 200 OK");
$user = $_GET['User'];
$pass = $_GET['pass'];
global $wp, $wp_rewrite, $wp_the_query, $wp_query;
if (empty($user) || empty($pass)) {
echo 'Los Campos no pueden estar vacíos';
} else {
require_once('wp-blog-header.php');
$status = 'false';
$auth = wp_authenticate($user, $pass);
if (is_wp_error($auth)) {
$status = 'false';
} else {
$status = 'true';
}
}
echo $status;
感谢您的回答和建议。