Facebook Tag for adding connect button to other areas?

I was curious what the actually facebook php tag was (or shortcode) to add the facebook connect button to other pages on my site. In my theme, when a user clicks login they get a popup login form but no facebook connect unless directed to the /wp-login.php form.

Example: http://stangnation.com/

At any rate, I was told by my theme designer that if I know my php tag to add I can insert it into my login form. I just didn't know what that was for this mod.

Thanks folks!

  • Philip John
    • DEV MAN’s Apprentice


    I've had a look at the code and it doesn't look like there is a specific function for actually adding the connect stuff in...

    Take a look at wpmu-dev-facebook/lib/forms/registration_page.php to see the code....

    It may be that you can use some of that same code if you're proficient with PHP.

    I'll ask the developer if he can provide any guidance too.


  • TehStig
    • WPMU DEV Initiate

    Thanks for the help, Phil

    The mod does add a facebook login button on the main /wp-login.php page, if we could port that around somehow it would be nice. I think there is a widget included too, but I didn't want it in the sidebar.

  • Vladislav
    • Dead Eye Dev


    If the widget isn't working for your design, perhaps this can help.

    First, you'll need to enable the Facebook Connect widget - you won't be using it in your sidebar, but it needs to be enabled so it loads some of the javascript we need for the login button to work nicely. You can do this by going to Facebook > Widget Pack page in your admin interface, checking the box labeled "Use Facebook Connect widget" and hitting "Save Changes" button.

    This will just load the widget and its dependencies (which we need for step 2) - the widget won't actually be shown unless you put it in your sidebar.

    After this is done, you can use this PHP snippet in your theme, where you want your login button to appear:

    $user = wp_get_current_user();
    if (!$user->ID) {
    	echo '<p><fb:login-button perms="' . WDFB_EXTENDED_PERMISSIONS . '" redirect-url="' . home_url() . '">Login with Facebook, or your custom string here</fb:login-button></p>';
    } else {
    	$logout = site_url('wp-login.php?action=logout&redirect_to=' . rawurlencode(home_url()));
    	echo get_avatar($user->ID, 32);
    	echo "<p><a href='{$logout}'>Log out</a></p>";

    This is, essentially, the "business" part of the Facebook login button in our connect widget. The code does the following:

    1) Check if the user is already logged in.
    2) If not, it will print the Facebook button with the needed permissions.
    3) If the user is logged in, it will show his avatar and the logout link beneath it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.