Honeypot for WordPress Comments and WPUF Forms

[themify_is_logged_in]

##################### Add Honeypot to WPUF Forms ########################

function wpuf_honeypot_field( $form_id, $form_settings ) {
    if ( $form_id != 1064 ) {
        return;
    }
?>
<li class="wpuf-el hide-robot">
	<div class="wpuf-label">
		<label for="firstname" >Firstname</label>
	</div>
	<div class="wpuf-fields">
		<input type="text" name="firstname" id="firstname" autocomplete="random_value" tabindex="-1" />
	</div>
</li>
<?php
}
add_action( 'wpuf_add_post_form_top', 'wpuf_honeypot_field', 10, 2 );

function wpuf_honeypot_validate( $error ) {
	if ( isset( $_POST['firstname'] ) ) {
		$honeypot = $_POST['firstname'];
		if( ! empty( $honeypot ) ){
			return __( 'Zur Zeit ist keine Übertragung möglich!' );
		}else{
			return'';
		}
	}
}
add_filter( 'wpuf_add_post_validate', 'wpuf_honeypot_validate' );

################### Add Honeypot to WP Comments ######################

/*** Added honeypot in the comment section ***/
/* Create a hidden item called confirmation input of the email address in the comment form */

function ha_honeypot_field( $postID ) {
?>
<p> <! ---  style="display:none" --->
	<label for="confirmationmail">Confirmation Email</label>
	<input type="text" name="confirmationmail" id="confirmationmail" autocomplete="random_value" tabindex="-1" />
</p>
<?php	
}
add_action( 'comment_form', 'ha_honeypot_field' );

/* If there is input in the hidden item, move it to spam */

function ha_honeypot_validate( $comment_status ) {
   if ( ! empty( $_POST['confirmationmail'] ) ) {
        $comment_status = 'spam';
    }
	return $comment_status;
}
add_filter( 'pre_comment_approved', 'ha_honeypot_validate' );

[/themify_is_logged_in]