Add JetPack Protect Humanity Check to Any Login Form

I work with Theme my Login and build member-based content areas within websites a lot. Often, the login forms that I use do not bring in the JetPack Protect prompt automatically, and users will have to submit the form two or three times in order to successfully login (once to see the humanity check, once to login, and possibly a third time depending on cache and browser settings).

I found this snippet within JetPack to generate the Protect humanity prompt:

<?php $salt = get_site_option( 'jetpack_protect_key' ) . get_site_option( 'admin_email' );
	$num1 = rand( 0, 10 );
	$num2 = rand( 1, 10 );
	$sum  = $num1 + $num2;
	$ans  = sha1( $salt . $sum );
	<div style="margin: 5px 0 20px;">
		<strong><?php esc_html_e( 'Prove your humanity:', 'jetpack' ); ?> </strong>
		<?php echo $num1 ?> &nbsp; + &nbsp; <?php echo $num2 ?> &nbsp; = &nbsp;
		<input type="input" name="jetpack_protect_num" value="" size="2" />
		<input type="hidden" name="jetpack_protect_answer" value="<?php echo $ans; ?>" />

Add before the form’s submit button.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.