605

Five Easy Steps to Integrate Facebook Connect with your WordPress Blog

Facebook Connect Integration in Five Easy Steps

Wondering how to seamlessly integrate Facebook Connect into your WordPress blog? Have no fear, Facebook Connect Man is here. Uh, well, not really, but read on if you want millions of people to be able to use their Facebook login for your blog!

1. Download and install the Facebook Connect Plug-in.

2. Create a new Facebook developer API key.

You don’t have to be a developer to get an API key. It just registers the usage of Facebook Connect so they can track where the API calls are coming from.

3. Edit your theme’s comments.php file.

You will want to dig through your comments.php file and add the following code just before or after your comment form:

<?php do_action('fbc_display_login_button') ?>

Then, you need to make sure your comments.php contains:

<?php if ( $user_ID ) : ?>

This will hide the name and email fields when a user is logged into Facebook Connect.

4. Activate the Facebook Connect plug-in and enter your API key and secret key.

Next, you need to go to your Plugins section in the WordPress admin and enable Facebook Connect. Then enter the API key and secret key that was generated in the second step.

5. Customize your CSS to make Facebook Connect look good.

Once you’ve installed Facebook Connect, it may look not so great. Customize the CSS to make it look like you and Facebook are best buds.

Customize the look of Facebook Connect

Here’s what I added to my CSS file to override some of the default styles that the Facebook Connect plugin adds to your page:

/* Facebook Connect Styles */

.facebook-connect{ /* I added this div wrapper myself, was not part of the plugin */
  position: relative;
  float: right;
  width: 300px;
  margin-top: -65px;
  text-align: right
}

.facebook-connect a,  /* you probably won't need this css */
.facebook-connect a:hover,
.facebook-connect a img,
.facebook-connect a:hover img{
  border: 0
}

.facebook-connect .fbc_connect_button_area { /* This is the button container for your comment form */
  border: 0;
  float:none;
  margin:0;
  padding:0
}

body .fbc_profile_header { /* I added body to override the CSS from Facebook Connect's default CSS */
  background:#000000 url("images/quote-bg-repeat5.jpg") repeat-x;
  border:1px solid #3d3e3d;
  border-right: 0;
  padding:10px 5px 5px 10px;
  position:fixed; top: 45%; right:0;
  text-align:left;
  width:220px
}

body .fbc_profile_header a.logout{ /* this is a custom class I added to the HTML in fbconnect.php */
  font-size: .9em;
  color: #999
}

That’s It, you should be up and running! However, if you are having issues with IE not displaying your button, WP SuperCache, or anything else, make sure to read the Frequently Asked Questions.

There are a number of other more detailed tutorials out there for you if you need a little more detail on the various steps.

Comments have been disabled for this post.
Sort: Newest | Oldest

Hi,
I implemented this on my website. I am able to connect to facebook, but after the page reloads and the login default comment form still appears with Name,Website,email-id. I guess once logged into facebook, it should not display the login form. Moreover can this login thing be ajaxified without reloading the page? What am I missing?

Hey chris why does this line appear in my front page : dir="ltr" lang="en-US" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;

Hey why does this line appear in my front page : dir="ltr" lang="en-US" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;

Hey I'm a total newb to Wordpress... Could you possibly help in total newb language? Where is the comment.php file? What EXACLTY do I have to add and where?

I love this idea just not much of a Wordpress guru. :(

It is dishonest to hide behind Facebook, refuse to talk with the media and to have someone else write for you because you are inarticulate. ,

This is a great plugin lad!

Facebook connect is really slowing down my page load time though!

Hey Chris, this is good, I couldn't get it working until I read this, BUT, when I click through, I get an error to do with the Connect URL, which I have no idea what to configure it as (Google is not helping, nor is the FBC Wiki) - though I imagine it kicks back to the page? Any help, and perhaps an addendum to this post, much appreciated.

Tim M
tdftips.com

Hi Chris,

Thanks for your informative post, I tried installing the plugin, but failed- got the below mentioned error.

Also- I added the code you mentioned in coments.php- but it doesn't work:

Warning: require_once(facebook-client/facebook.php) [function.require-once]: failed to open stream: No such file or directory in /home/www/atomthought.com/wp-content/plugins/wp-fbconnect/common.php on line 18

Fatal error: require_once() [function.require]: Failed opening required 'facebook-client/facebook.php' (include_path='.:/usr/local/php5/lib/php') in /home/www/atomthought.com/wp-content/plugins/wp-fbconnect/common.php on line 18

thanks for your help

Thanks! I'm editing the theme of my blog, and sorry for english errors, i'm a brazilian :)

Man, I'm sooo close. But for some reason, avatar's aren't resizing properly. And the comments aren't getting fed to Facebook at all.

Any thoughts?

http://www.jamesbull.ca/projects/snow/feature/mond...

I stopped reading the documentation for that plugin as soon as it said "creates a new WordPress user". Instant fail.

I want to have FB users have a button to easily put in their name/email information, but I don't want them to become some sort of permanent member of my site. My site has one user: me. It doesn't need to create users to let people leave comments.

Is there any plugin that doesn't do that? Or is this some kind of massive failing of Facebook Connect or what?

Awesome! Thank you for dropping your knowledge on us all!

*that might have been confusing. I already have a page with a large amount of fans and would like to connect that existing page.. not having to create a new one page and re-invite people.

Hey Chris,

This is great! I was wondering if you can set an already existing page - in this case my blog (Seizure Chicken) as the page to link fbook connect, rather than my actual profile or having to create a new page?

any help would be awesome! thanks

After driving myself crazy thank goodness I figured this out!

The last step where it says "Then enter the API key and secret key that was generated in the second step." you need to add "... under SETTINGS". I kept going to the code under Plugins trying to figure out where to plug in the API and secret code. It was the instructions that I linked to from your FAQ that I figured this out.

http://wiki.developers.facebook.com/index.php/WP-F...

Thanks for these instructions though.

* going back to continue figuring this out *

but it doesn't show a person's picture ... hmmmph ..need to look into it :)

I have a contol question..
If you hold and moderate comments on a WP blog, does FB connect override that moderation or are they held in the same way? If they are held, then do they stay off a FB feed until approved?

Well... I tried implementing Facebook Connect on my site... unfortunately the button refuses to show up! Do you think you could help with some support?

Hello Chris - Thanks for the helpful outline of steps for FB Connect!

I am using your awesome theme Absynthe and followed your directions above to a t. This is the error message I get where the comments are:

Parse error: syntax error, unexpected $end in /home/catherinescholz/blog.catherinesmusic.com/wordpress/wp-content/themes/absynthe/comments.php on line 102

Any ideas?

Thanks,
Catherine

How do you delete/edit comments made on your blog via facebook connect? I'm sure we will get some that violate our terms.

When I install it and click Facebook Connect it comes up with an Under Contrustion page. Someone help me pelase! www.thedevil.me.uk

Wonderful post sir, thanks for taking the time to put this together. I was able to add this to my blog in no time. But I do think having a little more detail on setting up the Facebook app, might save a little time digging. Thanks again!

Hi again Chris - sorry, please ignore my last post. I was being thick. It all works now so thank-you! The only issue I have is with the "Facebook User" too...

Hey, this is a great, very clear tutorial. Thank-you!

I have one problem though, I'm being stupid because when I get to: "Then enter the API key and secret key that was generated in the second step" I don't know where to enter these. Am I being really thick?

Nice tutorial. it worked great...just have to figure out how to move my welcome box and integrate facebook avatars.

Hmmm why do I become "Facebook User" and not my real name?

Are you still using Facebook Connect with your comment system? Can't seem to locate the Facebook Connect button anywhere. Just commenting to test out whether it'll link up with my FB account.

Awesome tutorial though.

I was using it but turned it off due to a Javascript error. I have turned it back on if you'd like to see it in action.

I did have the same error on my site. I ran php5 on my server then it solved the problem (PHP5 is required).

it is helpful, thanks

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/gadgetst/public_html/nokiaweblog/wp-content/plugins/wp-facebookconnect/fbconnect.php on line 38

what to do? thanks.

Thanks a lot, I followed up this great tutorial and I have it now running on my site, Los Santos del Indie. Greetings from Argentina!

No it does not, any idea on how to make it do that?

yeah, I have the same query as wang...will it post news feed? if so ...its a great way to market your blog!

Follow-up question... did you have to modify the comments.php so that the facebook avatar (profile pic) would show up?

I like this, very helpful thanks!

Yes, it's highly possible your theme will already have that in the comments.php file. However, you do need to check and make sure.

Clarification please:

***
Then, you need to make sure your comments.php contains:

***

Does this mean that that string probably already exists in the comments file?

Cool, i will use it.

Wow.. this is an incredible addtion!!

Does the plugin post stories to the news feed for you?

This is a great plugin