Php wp_登录_表单身份验证问题

Php wp_登录_表单身份验证问题,php,wordpress,Php,Wordpress,大家好,我的社区, 我需要帮助解决我的WordPress登录验证问题。所以我已经安装了最好的Capatha。。。为了将capatcha放入自定义wp_登录表单中,我需要添加验证。所以我创造了这个: add_filter( 'wp_authenticate_user', 'my_custom_authenticate', 10, 3 ); function my_custom_authenticate( $user, $username, $password ){ //Get POSTED

大家好,我的社区, 我需要帮助解决我的WordPress登录验证问题。所以我已经安装了最好的Capatha。。。为了将capatcha放入自定义wp_登录表单中,我需要添加验证。所以我创造了这个:

add_filter( 'wp_authenticate_user', 'my_custom_authenticate', 10, 3 );
function my_custom_authenticate( $user, $username, $password ){
    //Get POSTED value
    if ( ( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) || ( function_exists( 'cptchpr_check_custom_form' ) && cptchpr_check_custom_form() !== true ) ) { 
      remove_action('authenticate', 'wp_authenticate_username_password', 20);
      $user = new WP_Error( 'denied', __("<strong>ERROR</strong>: You're CAPTCHA field was wrong.") );
    }
    return $user;
}
你有没有遇到过这个问题,我怎么能解决呢

继续采用“尝试失败”的方法

使用
var_dump()
检查
if
语句中每个条件的值

大概是这样的:

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;
}
add_filter('wp_authenticate_user','my_custom_authenticate',10,3);
函数my\u custom\u authenticate($user、$username、$password){
/**这是调试部分*/
变量转储(函数存在('cptch\u check\u custom\u form');
变量转储(cptch\u check\u custom\u form());
变量转储(函数存在('cptchpr\u检查\u自定义表单');
变量转储(cptchpr检查自定义表单()!==true);
/**结束调试部分*/
//获取入账价值
如果(
(函数_存在('cptch_check_custom_form')&&true!==cptch_check_custom_form())
||(函数_存在('cptchpr_check_custom_form')&&true!==cptchpr_check_custom_form())
{ 
删除操作(“身份验证”、“wp身份验证”、“用户名密码”20);
$user=new WP_Error('denied',uu(“Error:您的验证码字段错误”);
}
返回$user;
}

注意:我已使用更安全的更改了条件。

我不确定如何解决您的问题,但我可以推荐此插件。标准登录页面的设置很简单,可能值得一看-您的if语句中的cptch_check_custom_表单是否应该是cptch_custom_表单?@danjah仍然没有什么…:/检查if中的每一条语句,以了解其中哪一条返回了错误的值。使用
var\u dump()
打印其当前值,并查看它是否为预期值。如果,
中有四个复选框:其中一个不正确,您需要了解哪个不正确。@Aerendir要查看var dump,我应该启用调试器吗?
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;
}