September 12, 2018
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 ?> + <?php echo $num2 ?> = <input type="input" name="jetpack_protect_num" value="" size="2" /> <input type="hidden" name="jetpack_protect_answer" value="<?php echo $ans; ?>" /> </div>
Add before the form’s submit button.