2012-08-22 18 views
0

我爲網站訪問者提供一個自定義的登錄頁面,並希望包括登錄Facebook的按鈕,使應用程序檢查用戶的電子郵件是否註冊,如果是的話,它會記錄用戶英寸Facebook登錄WordPress的沒有一個插件

使用wp_signon我可以通過提供電子郵件和密碼登錄用戶,但在這種情況下,我沒有用戶的密碼,所以有沒有辦法,我可以提供一個Facebook登錄按鈕不使用插件?

回答

-1

使用此代碼並更換APP ID與你的域...

<html> 
    <head> 
     <title>Login with Facebook</title> 
    </head> 
    <body> 

     <div id="fb-root"></div> 
     <script> 
     window.fbAsyncInit = function() { 
      FB.init({ 
     appId  : 'YOUR_APP_ID', // App ID 
     channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
     }); 
    }; 
    // Load the SDK Asynchronously 
    (function(d){ 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 
    </script> 

    <div class="fb-login-button">Login with Facebook</div> 

</body> 

0

如果你想這樣做沒有插件,那麼你需要自己執行的OAuth。您可以使用這篇文章作爲參考,從頭開始爲您的主題創建一個Facebook登錄按鈕,無需插件。

WordPress Frontend Facebook Login