只需在自定义登录表单中使用隐藏字段:
<input type="hidden" name="custom-login" value="1" />
并连接到wp登录表单(页眉、页脚或表单本身):
add_action( \'login_head\', \'failed_login_message\', 10, 0 ); // display message at top of page
// add_action( \'login_footer\', \'failed_login_message\', 10, 0 ); // display at bottom of page
// add_action( \'\'login_form_login\', \'failed_login_message\', 10, 0 ); // display message WITHIN the form
function failed_login_message() {
// bail if the user does not come from the custom login form
if ( ! isset( $_POST[\'custom-login\'] ) || true != $_POST[\'custom-login\'] )
return false;
echo \'<p class="error">Something went wrong. Your login data wasn\\\'t correct. Try again.</p>\';
return true;
}