我正在为 wordpress 制作一个简单的 javascript 登录表单。我有表单提交到以下 php 位来处理登录:
<?php
get_header();
global $user_ID;
if (!$user_ID) {
if($_POST){
//We shall SQL escape all inputs
$username = $wpdb->escape($_REQUEST['username']);
$password = $wpdb->escape($_REQUEST['password']);
$remember = $wpdb->escape($_REQUEST['rememberme']);
if($remember) $remember = "true";
else $remember = "false";
$login_data = array();
$login_data['user_login'] = $username;
$login_data['user_password'] = $password;
$login_data['remember'] = $remember;
$user_verify = wp_signon( $login_data, false );
//wp_signon is a wordpress function which authenticates a user. It accepts user info parameters as an array.
if ( is_wp_error($user_verify) )
{
echo "<span class='error'>Invalid username or password. Please try again!</span>";
exit();
} else
{
echo "<script type='text/javascript'>window.location='". get_bloginfo('url') ."'</script>";
exit();
}
} else {
//get_header();
?>
关于我为什么会收到错误的任何想法?干杯,丹