我已经成功将WordPress登录表单嵌入到我的网站前端,以允许用户无需访问wp-login.php或离开“主题”或网站即可登录。
如果您访问http://westendmediacentre.com/dev并点击登录,您会发现该表单出现在一个jQuery弹窗中。我的代码如下:
表单代码:
这很完美,但是如果您尝试使用错误的凭据登录,则会被重定向到一个WordPress页面,显示错误信息。
我想要做的是,在我的jQuery弹出窗口中显示这些错误,因此当您尝试使用错误的凭据登录时,它会在表单上方或下方显示错误消息,而不是重定向到另一个页面并在那里显示错误。
我尝试遵循这个教程,但它与我的现有代码不兼容:http://www.tutorialstag.com/custom-wordpress-login-without-using-a-plugin.html 如果有人能发布一个可行的解决方案,将不胜感激。
如果您访问http://westendmediacentre.com/dev并点击登录,您会发现该表单出现在一个jQuery弹窗中。我的代码如下:
表单代码:
<div class="login-form">
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
<input type="text" name="log" id="log" value="Username<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" class="login-fields" onclick="this.value='';" onblur="this.value=!this.value?'Username':this.value;"/>
<input type="password" name="pwd" id="pwd" value="Password" size="20" class="login-fields" onclick="this.value='';" onblur="this.value=!this.value?'Password':this.value;"/>
<input type="submit" name="submit" value="Login" class="login-button" />
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
</form>
</div>
jQuery:
$('.button-login').click(function() {
$('.login-box').fadeIn('slow', function() {
// Animation complete
});
$(".login-box").css({'z-index' : '10000'});
$("#the-lights").css({'display' : 'block'});
$("#the-lights").css({'z-index' : '1'});
$("#the-lights").fadeTo("slow",0.7);
});
$('.login-box-close').click(function() {
$('.login-box').fadeOut('fast', function() {
// Animation complete
});
$("#the-lights").fadeTo("slow",0);
$("#the-lights").css({'display' : 'none'});
});
这很完美,但是如果您尝试使用错误的凭据登录,则会被重定向到一个WordPress页面,显示错误信息。
我想要做的是,在我的jQuery弹出窗口中显示这些错误,因此当您尝试使用错误的凭据登录时,它会在表单上方或下方显示错误消息,而不是重定向到另一个页面并在那里显示错误。
我尝试遵循这个教程,但它与我的现有代码不兼容:http://www.tutorialstag.com/custom-wordpress-login-without-using-a-plugin.html 如果有人能发布一个可行的解决方案,将不胜感激。