传递WordPress凭据不工作。请协助

时间:2015-01-11 12:10:26

标签: php wordpress variables login single-sign-on

在最后几周击败自己头脑后,我需要寻求帮助。从理论上讲,这应该很简单。

我正在尝试为自定义登录系统创建WordPress SSO。当用户登录到WordPress网站(或(更改密码或电子邮件)时,它将在用户通过Wordpress验证后启动SSO功能。

我的问题是哪个直接挂钩正确用于此任务以及哪个变量可用于此任务。当访客成功登录Wordpress时,它会使用相同的用户凭据来验证自定义系统登录。

function custom_login() {
//## Function used to 'Auto' Login to Custom if user is accepted from WordPress.


    //## Check if user is signed on.
    if ( !is_user_logged_in() ) {

       //## User is Not Logged in, return 'false'
       return;

    }


    //## Assign Varibles (is this too risky?)
    //## Not sure if the $_POST['value'] will be the best way for this.
    $NewUserCred_username  = $_POST['log'];
    $NewUserCred_password  = $_POST['pwd'];


    //## Fire up Custom Validation. 
    //## Will set Custom Session if Successful.
    fireCustomLoginFunction($NewUserCred_username, $NewUserCred_password);


}


//## Maybe should run this during wp_signon or wp_login?
add_action( 'NOT SURE', 'custom_login' );

似乎wp_signon是以某种方式使用的,因为它包含我需要用来在散列之前传递给函数的凭据,但那时用户还没有被验证。自定义系统重新散列信息以确保安全。

我的问题是哪个直接挂钩正确用于此任务以及哪个变量可用于此任务。有任何想法吗?任何反馈都是真的很感激

:)

1 个答案:

答案 0 :(得分:1)

尝试

 add_action( 'after_setup_theme', 'custom_login', 100 );

function custom_login() {
   //## Function used to 'Auto' Login to Custom if user is accepted from WordPress.


//## Check if user is signed on.
if ( !is_user_logged_in() ) {

   //## User is Not Logged in, return 'false'
   return;

}


//## Assign Varibles (is this too risky?)
//## Not sure if the $_POST['value'] will be the best way for this.
$NewUserCred_username  = $_POST['user_login'];
$NewUserCred_password  = $_POST['user_email'];


//## Fire up Custom Validation. 
//## Will set Custom Session if Successful.
fireCustomLoginFunction($NewUserCred_username, $NewUserCred_password);


}