So ive been trying to add a honey pot to my Wordpress Login, but its not working how I think it should.
I want to the login to redirect when the login form is filled out and there is any text in the Honey Pot form field.
This is how I am trying to add the form field and handle the form:
//LOGIN HONEYPOT
add_action('login_form','myLogin_honeypot_form');
function myLogin_honeypot_form (){
$body = ( isset( $_POST['body'] ) ) ? $_POST['body']: '';
?>
<p id="notTher">
<label for="body"><?php _e('If you can see the below box, do not input any text. This is a test.','mydomain') ?><br />
<input type="text" name="body" id="body" class="input" value="<?php echo esc_attr(stripslashes($body)); ?>" size="25" /></label>
</p>
<?php
}
function myLogin_HoneyPot_Error(){
if($_POST['body'] != null){
wp_redirect( site_url().'/wp-login.php' );
}
}
add_filter('login_form','myLogin_HoneyPot_Error');
The new field shows fine, and it redirects properly BUT only if an invalid username is password is entered, if a valid user name and password is entered, the form logs the user in, But i want it to redirect before processing the login and password fields so that the user will not be logged in.
Thanks.