Wordpress(wp_signon)将我视为未登录用户

时间:2014-12-02 10:55:27

标签: php wordpress

我有两个门户网站,一个是jsp,另一个是wordpress,我正在尝试为两个门户网站进行通用登录(即当用户从jsp登录时同时需要登录wordpress)。所以我写下波纹管代码

$creds['user_login'] =$userid[0];
    $creds['user_password'] = $user_password;
    $creds['remember'] = true;
    $user = wp_signon( $creds, false );
       // print_r($user);
    if ( is_wp_error($user) ){
        echo $user->get_error_message();
}else{
//echo $user->ID.'dd';
get_currentuserinfo($user->ID);
$user_id = $user->ID;
$user = get_user_by( 'id', $user_id ); 
if( $user ) {
    wp_set_current_user( $user_id, $user->user_login );
    wp_set_auth_cookie( $user_id );
    do_action( 'wp_login', $user->user_login );
}
global $current_user;
      get_currentuserinfo();

      //echo 'Username: ' . $current_user->user_login . "\n";

使用上面的代码,我可以登录用户详细信息...但是当我尝试去管理员时,它要求登录凭据

1 个答案:

答案 0 :(得分:0)

我不知道这两个网站的设置是什么,但您是否尝试更改wordpress网站中的Cookie常量?

http://codex.wordpress.org/Editing_wp-config.php#Set_Cookie_Domain http://codex.wordpress.org/Editing_wp-config.php#Additional_Defined_Constants