2012-01-19 32 views
3

集成WordPress的認證。我在那有領域的用戶表的數據庫:與現有的用戶數據庫

id 
name 
email 
password 
status 

我的用戶給予的電子郵件地址和密碼登錄。我已經安裝了一個名爲mysite.com/news的博客。

我想要的是,如果一些用戶在我的網站註冊它應該會自動添加一行在我的wordpress數據庫。我想獲取我用戶表的所有記錄並存儲在wordpress用戶表中。另外,如果有人在我的網站上登錄,它應該在他們訪問博客時登錄。

+1

相關:[同步WordPress用戶帳戶跨多個域和裝置,而不使用WordPress MU](http://wordpress.stackexchange.com/questions/3924/synchronize-wordpress-user-帳戶跨多個域和安裝wi) – hakre

回答

5

爲什麼複製信息?您還必須採取措施在兩個數據庫之間獲得一致的用戶管理。

我建議使用現有的數據庫作爲WordPress的身份驗證源使用此插件:http://wordpress.org/extend/plugins/external-database-authentication/

更新:

要允許用戶將已經登錄到WordPress,設置WordPress的認證當他們在您的網站上登錄時Cookie。您可以通過包含所需的最低WordPress代碼並調用wp_setcookie()函數來完成此操作。

// include the wordpress files necessary to run its functions 
include('../classpages/wp-config.php'); // this includes wp-settings.php, which includes wp-db.php, which makes the database connection 
include(ABSPATH . WPINC . '/pluggable-functions.php'); 

// use wordpress's function to create the login cookies 
// this creates a cookie for the username and another for the hashed password, which wordpress reauthenticates each time we call its wp_get_current_user() function 
wp_setcookie($user_login, $user_pass, false, '', '', $cookieuser); 

Using wordpress login functions

+0

它不工作時,我激活它的送禮者mysql錯誤像一些 – user1138383

+0

Thanx其工作完美。現在我想知道,如果有一些用戶在我現有的網站登錄,他來到博客。他的會議應該與我現有的會場相同。我可以這樣做嗎? – user1138383

+0

在哪裏保持這個功能?你能解釋一些嗎 – user1138383