<?
function bd_login_form()
{
?>
<p>
<label for="user_pass_2">身份确认码<br />
<input type="password" name="pwd_2" id="user_pass_2" value="" size="20" tabindex="20" /></label>
</p>
<?
}
add_action('login_form', 'bd_login_form');
function bd_authenticate_username_password($user, $username = '', $password = '')
{
if ( isset($_POST['log']) )
{
$bDone = false;
if ( isset( $_REQUEST['pwd_2'] ) )
{
$pwd2 = $_REQUEST['pwd_2'];
if ( $pwd2 === '123' ) // 自由发挥
$bDone = true;
}
if ( $bDone == false )
{
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
$error = new WP_Error();
$error->add('incorrect_password', __('<strong>错误</strong>:身份确认码不正确。'));
return $error;
}
}
return $user;
}
add_filter('authenticate', 'bd_authenticate_username_password');
?>
直接放到主题的functions.php内就用得了,或者自己整成插件。