This is the info on Facebook Login button
http://developers.facebook.com/docs/guides/web/
So it will render a Login button, and a user can click on it to log in on Facebook (a log in window will pop up) But after the user logs in, even though the Like or Share buttons work now, but the Log in button still shows.
1) Is there a way to redirect to a URL after the user successfully logs in?
2) Another way is to dynamically change the Log in button to invisible or better yet, show it as "Logged in as [Peter (username)]"
How can (1) and/or (2) be done? (I don't see a callback URL in the Facebook app setting and also the redirection may need to go to different URL from page A or page B on the website)
Update: I found some info about <fb:login-button on-login="top.location = '...'; ">
but I see some website doing the redirect but there is no on-login='...'
The most common ways to implement redirection logic after login are: using HTTP Referer header. saving the original request in the session. appending original URL to the redirected login URL.
#3: Set Up Facebook Login for Your Website At this point, you'll see Facebook Login among your website app options. Click the Set Up button to get started. Next, you'll fill in the information about how and where you'll use the app. You can add the Facebook Login feature on any app across multiple devices.
Click Use My Domain on the domain you want to connect to your Facebook page. Click Connect to an Existing Site. Select the Facebook option under the Social Sites section. Type in your Facebook URL, which you can find in the General Account Settings on your Facebook page.
1) You can also redirect on login using some code like this (note the auth.login
event):
<script src="http://connect.facebook.net/en_US/all.js"> </script> <script> FB.init({ appId: '??????????????', cookie: true, status: true, xfbml: true }); FB.Event.subscribe('auth.login', function () { window.location = "http://example.com"; }); </script> <fb:login-button> Login with Facebook </fb:login-button>
2) To determine whether to show or hide the login button, you can use FB.getLoginStatus
to discover whether the user is logged in. The following page might be of use: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With