簡體   English   中英

用我的自定義 Web 應用程序登錄替換 wordpress 登錄

[英]replace wordpress login with my custom web application login

我正在開發一個 Web 應用程序,用戶可以在其中注冊、登錄和社交登錄。 在同一個應用程序中我也需要一個博客。 我選擇wordpress。

但問題是如果用戶已經在我的應用程序上擁有帳戶,他/她可以使用相同的會話管理在 wordpress 上使用相同的憑據登錄。

是否有可能以及如何替換 Wordpress 登錄?

您可以通過以下方式進行操作:

將 wordpress 文件夾名稱 blog/ 保留在您的項目根目錄中。 然后使用與您的應用程序相同的憑據創建 wordpress 用戶。 創建新登錄用戶時,將以下代碼放入您的應用程序中:

require_once('blog/wp-blog-header.php');
require_once('blog/wp-includes/registration.php');
$newusername = 'xxxxxxxxxxx';
$newpassword = 'xxxxxxxxxxx';
$newemail = 'xxxxxxx@xxxxxxx.co.in';
// Check that user doesn't already exist
if ( !username_exists($newusername) && !email_exists($newemail) ){
   // Create user and set role to administrator
   $user_id = wp_create_user( $newusername, $newpassword, $newemail);
   if ( is_int($user_id) )      {
       $wp_user_object = new WP_User($user_id);
       $wp_user_object->set_role('contributor');
            echo 'Successfully created new user.';
    } else {
            echo 'No users were created.';
    }
} else {
    echo 'This user or email already exists. Nothing was done.';
}

希望這會有所幫助。

不確定我是否理解你的意思...但是你寫道:他/她可以使用相同的會話管理在 wordpress 上使用相同的憑據登錄。

你確定你不是說不能? 否則我看不出你的問題...

但是如果你的意思是不能......所以,我不知道現在的 wordpress 怎么樣,但我大概三年前嘗試過同樣的事情......最終我編寫了自己的博客,花了我更少的時間而不是處理所有這些 wordpressstuff。 順便說一句,編寫自己的博客應用程序真的很容易......有 100 個教程,如果你願意,我可以幫助你,應該不是問題......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM