Solution:
Proceed with a “try and fail” approach.
Use var_dump()
to check the values of each single condition in your if
statement.
Something like this:
add_filter( 'wp_authenticate_user', 'my_custom_authenticate', 10, 3 );
function my_custom_authenticate( $user, $username, $password ){
/** THIS IS THE DEBUGGING PART */
var_dump(function_exists( 'cptch_check_custom_form' ));
var_dump(cptch_check_custom_form()));
var_dump(function_exists( 'cptchpr_check_custom_form' ));
var_dump(cptchpr_check_custom_form() !== true);
/** END DEBUGGING PART */
//Get POSTED value
if (
( function_exists( 'cptch_check_custom_form' ) && true !== cptch_check_custom_form() )
|| ( function_exists( 'cptchpr_check_custom_form' ) && true !== cptchpr_check_custom_form() ) )
{
remove_action('authenticate', 'wp_authenticate_username_password', 20);
$user = new WP_Error( 'denied', __("<strong>ERROR</strong>: You're CAPTCHA field was wrong.") );
}
return $user;
}
NOTE: I’ve changed the conditions using the Yoda’s notation that is more secure to use.