如果您希望而不是重定向到wp-login
用户重定向到login
第页,然后使用以下代码。它将用户重定向到login
显示登录表单的页面。
add_filter(\'site_url\', \'wplogin_filter\', 10, 3);
function wplogin_filter( $url, $path, $orig_scheme ){
$old = array( "/(wp-login\\.php)/");
$new = array( "login/");
return preg_replace( $old, $new, $url, 1);
}
add_action(\'init\',\'possibly_redirect\');
function possibly_redirect(){
global $pagenow;
if( \'wp-login.php\' == $pagenow ){
wp_redirect(site_url( $path = \'login\'));
exit();
}
}
在登录表单中,检查操作的值。供登录使用
wp_signon()
作用
if(!isset($_REQUEST[\'action\'])) { ?>
<div>Login with the Email
<form id="login-form" action="<?php echo $_SERVER[\'REQUEST_URI\'] ?>" method="post">
<table style="float: left;">
<tr>
<td><label>User Name</label></td>
<td>
<input type="text" name="user_name" id="user_name" placeholder="Enter your username">
</td>
</tr>
<tr>
<td><label>Password</label></td>
<td>
<input type="password" name="password" id="password" placeholder="Enter password"><br>
<a href="<?php echo site_url(\'login/?action=lostpassword\') ?> "> Forgot Your Password ? </a><br>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" id="login-submit" value="Login"></td>
</tr>
</table>
</form>
<?php
}
密码丢失。以相同的格式创建表单
login page
if(isset($_REQUEST[\'action\']) && \'lostpassword\'== $_REQUEST[\'action\'])
{
?>
<div id="tab3_login" class="tab_content_login" >
<p>Enter your username or email to reset your password.</p>
<form method="post" action="<?php echo site_url(\'login/?action=tg_pwd_reset\') ?>" class="wp-user-form">
<div class="username">
<label>Username or Email : </label>
<input type="text" name="user_login" value="" size="20" id="user_login" />
<?php toolTip(\'user_login\', \'Username\');?>
</div>
<input type="submit" name="user-submit" value="<?php _e(\'Reset my password\'); ?>" class="user-submit" tabindex="1002" />
</form>
</div>
<?php
}