Facebook Connect:Login
The FBC:Login tag allows you to display a Facebook login (and logout) button on your page. It shows the appropriate button depending on the current user's FB login state. Additionally, you can set return pages for every scenario possible when logging in/out.
{exp:fbc:login} content {/exp:fbc:login}

Parameters
The following parameters are available for use:
- login_button_label
- logout_button_label
- button_size
- show_faces
- max_rows
- width
- permissions
- return_when_logged_in
- return_when_logged_out
- return_to_register
- return_for_passive_register
- return_to_confirm_account_sync
- return_on_failure
- ignore_ee_login
login_button_label=
login_button_label="Facebook Login"
Use this parameter to change the text label of the Facebook Login button. For example, you can type in a value of Login with Facebook or Connect with Facebook.
logout_button_label=
logout_button_label="Facebook Logout"
Use this parameter to change the text label of the Facebook Logout button. For example, you can type in a value of Logout of Facebook.
button_size=
button_size="medium"
Use this parameter to change the size of the Facebook Login button. You can only choose from predetermined options from Facebook: small, medium, large, or xlarge.
show_faces=
show_faces="true"
This parameter allows you to specify whether to display profile photos of the users' friends below the Login button.
max_rows=
max_rows="1"
This parameter controls the total number of rows of friends pictures to add under the Login button.
width=
width="400"
This parameter controls the width (in pixels) of the Login pop-up.
permissions=
permissions="email|publish_stream|read_stream"
This parameter allows you to provide a list of permissions (seperate with pipe character) to request from the user while they login as below:
- email - this permission grants the EE site permission to send email to the user's actual email address (not the proxied FB email address). If using Passive mode registration on your site, the users' real email address will be stored in the email field for their "dummy" EE member account.
- publish_stream - this permission allows the current site to submit a user's comments and other submissions up to their FB wall or news stream.
- read_stream - this permission allows the current site to read from a user's FB stream and grab stuff like comments and statuses and the like.
- The above 3 permissions are the main ones you'll need. You can view the full list of permissions in the Facebook Permissions Documentation. Use the names mentioned in the User permission column.
return_when_logged_in=
return_when_logged_in="fbc/home"
The module attempts to sync a users FB account with the EE account to which they are logged in whenever it can. If someone is logged into an eligible EE member account and they login using the FB login_button, their accounts will be synced and they will be redirected to this URL. If someone logs into FB and an EE account is found that is already synced, they are logged into that EE account and redirected to this url.
return_when_logged_out=
return_when_logged_out="fbc/home"
This is where you specify the return path for when FB logout is completed by a user.
return_to_register=
return_to_register="fbc/register"
If someone attempts to Facebook login and they are not a logged-in EE user they are redirected to this page. On this page, you would typically have the FBC:Registration form. You could alternately display a page that describes the Facebook login/registration process to the user, and then have them click another button to continue to the Register form. This parameter will be ignored if you have the Passive Registrations preference set to Yes in the FBC control panel.
return_for_passive_register=
return_for_passive_register="fbc/home"
If you have the Passive Registrations preference set to Yes in the FBC control panel, this parameter lets you control the return page once the user becomes Facebook logged in. Passive Registration means that the user will just see a Facebook prompt to allow your site to connect to their profile, and then FBC will automatically create a dummy regular ExpressionEngine member account and sync the Facebook account to it.
return_to_confirm_account_sync=
return_to_confirm_account_sync="fbc/confirm_sync"
If you have the Confirm Account Sync preference set to Yes in the FBC control panel, this parameter lets you control the return page when a user attempts to Facebook login, and is already logged into ExpressionEngine.
return_on_failure=
return_on_failure="fbc/fail"
When all of the login/register possibilities available in the FB login routine are exhausted and failed, the logging in user is redirected to this URL.
ignore_ee_login=
ignore_ee_login="yes"
This parameter ignores a check on whether or not a user visiting your site is logged into your EE site. This is useful if you want to ONLY check if the user visiting your site is logged into Facebook.
Variables
The following variables are available for use:
fbc_login_button
{fbc_login_button}
This variable parses as a Facebook Login button.
fbc_logout_button
{fbc_logout_button}
This variable parses as a Facebook Logout button if the user is Facebook logged in, or otherwise parses as an empty string.
Conditionals
The following conditionals are available for use:
if fbc_logged_in
{if fbc_logged_in == "y"}{/if}
This conditional displays it's contents if the user is logged into both Facebook and EE and the two accounts are synced.
if fbc_logged_out
{if fbc_logged_out == "y"}{/if}
This conditional displays it's contents if the user is currently not logged into a synced Facebook and EE account. So for example, this will conditional will evaluate to y under the following conditions:
- user is logged into just EE
- user is logged into just Facebook
- user is logged into both EE and Facebook, but the two accounts have not yet ever been synced
- user is not logged into EE and Facebook
Examples
Below is some example code on how to display a basic login/logout button for FB users. It will show a Facebook Login button if the user is NOT logged into Facebook and EE (synced), and if they’re logged into Facebook and EE (synced), it displays an EE Log Out link for them to log out of your site (EE) only. You could instead display a Facebook Logout button that lets them log out of both your site (EE) and Facebook, but it seems more courteous to the user to just log out of your site:
{exp:fbc:login
permissions="email|publish_stream|read_stream"
return_when_logged_in="site/home"
return_when_logged_out="site/home"
return_to_register="site/register"
return_on_failure="site/fail"
}
{if fbc_logged_out == "y"}{fbc_login_button}{/if}
{if fbc_logged_in == "y"}<a href="{path='logout'}">Log Out</a>{/if}
{/exp:fbc:login}


