Posts Tagged ‘WP-FBConnect’

Adding Facebook Connect to your WordPress Blog

August 9th, 2009

Today I added ‘Facebook Connect‘ to my blog and I was running into two or three caveats. I want to share my trial-and-error experience from today with you.

First, I downloaded the WP-FBConnect plugin, installed & activated it in the wp-admin. After reading myself trough the Wiki and Adam Breckler’s tutorial I was ready to set up the required Facebook Application.

Having entered only the minimal required information to get the WP-FBConnect plugin up and running, I tried to login to my site with my Facebook account. It worked fine and I was able to post a comment.

After that I wanted to do some customizations and here’s where the problems started:

  • Infinite redirect loop when trying to log out
    Reason: http://forum.developers.facebook.com/viewtopic.php?id=32640
    Solution: Clear all your browser cookies (or at least all cookies from the affected domain). Don’t use the ‘base domain’ field in the Facebook Application settings.
  • Logged in as “Facebook User”, Username is not displaying correctly
    Reason: http://wordpress.org/support/topic/234687 (first post from ahupp). You may also want to read this post.
  • Facebook users have access to wp-admin
    This was the biggest issue as I really don’t want to expose anything from the WP back-end to ‘Subscribers’. My solution is simple: add the following code to your themes ‘functions.php’:
1
2
3
4
5
6
7
# Disable access to wp-admin for Facebook users
if ( is_admin() ) {
    global $current_user;
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);
    if ( !is_null($user_info->fbuid) ) die( 'No access for Facebook users!' );
}

If you want to change the appearance of the FB login button, you can do so by updating the code at line 99 of ‘common.php’ according to the attributes described here.

If you run into more issues with the plugin, please read the section ‘Troubleshooting / FAQ’ outlined in this document.

Happy Facebook-Connecting!