Facebook Tag for adding connect button to other areas?

Hello,
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!

  • Vladislav

    Hi,

    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:

    <?php
    
    $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.