0
我正在與wordpress進行laravel整合。我有一個可以選擇轉到wordpress項目的儀表板,但目前它不工作。這個想法是有一個重定向到wp-admin的自動登錄。 laravel數據庫中的用戶必須與wp數據庫中的相同。所以它只能通過用戶wp不能在wp-database中創建一個新的。我有一個全球性的訪問laravel核心。嘗試創建一個類與用戶的憑據,將作爲對象傳遞給wordpress。有人準備好幫助嗎?由於WordPress自動登錄
我的WordPress登錄代碼:
if(!is_user_logged_in()){
$User = new myadmin_user;
$userid = $User->ID;
if($User=get_user_by('login',$userid)){
clean_user_cache($User->ID);
wp_clear_auth_cookie();
wp_set_current_user($User->ID);
wp_set_auth_cookie($User->ID , true, false);
update_user_caches($User);
if(is_user_logged_in()){
$redirect_to = user_admin_url();
wp_safe_redirect($redirect_to);
exit;
}
}
}
elseif('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] == wp_login_url()){
$redirect_to = user_admin_url();
wp_safe_redirect($redirect_to);
exit;
}
和類:
class myadmin_user
{
public $ID;
public $username;
public $email;
public $status;
public $settings;
/**
* Object constructor
*
* @param
* @param
*/
function __construct()
{
global $appsforcekernel;
$this->settings = Auth::user()->getUserSettings(100000002);
$appsforceuser = Auth::user();
$this->ID = $appsforceuser->id;
$this->username = $appsforceuser->username;
$this->email = $appsforceuser->email;
$this->status = $appsforceuser->status;
$this->settings = $appsforceuser->settings;
}
}