× Joomla Facebook Connect support forum

Topic-icon Login button code?

11 years 3 months ago #29147 by chramb1
Login button code? was created by chramb1
So I've put the below code into my template, but it's not behaving as expected. Even when $user->guest is true, meaning I'm not logged in to my Joomla site, I'm logged in to Facebook, so what I see is NOT the "login with facebook" button, but the "Christopher Ambler likes element67" message (element67 is the name of my app on facebook for logins) and my small face avatar.

Am I doing it wrong?
if (class_exists("JFBConnectFacebookLibrary"))
{
  $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();

  $user = JFactory::getUser();

  if ($user->guest)
  {
    $fbLogin = $jfbcLibrary->getLoginButton('medium', 'true', 2);
  }
  else
  {
    $fbLogin = $jfbcLibrary->getLogoutButton();
  }

  echo $pre . $fbLogin . $post;
}

PS: $pre and $post contain the div code which will not reproduce here in your forum since it's HTML code.
The topic has been locked.
11 years 3 months ago #29149 by chramb1
Replied by chramb1 on topic Login button code?
Okay, I tried replacing the above code with:
  $renderKey = SCSocialUtilities::getJFBConnectRenderKey();
  echo '{JFBCLogin logout=false' . $renderKey . '}';

... which works. So can you clue me into why this works and the above code does not?
The topic has been locked.
Support Specialist
11 years 3 months ago #29156 by alzander
Replied by alzander on topic Login button code?
There's a bug with the Javascript Login button from Facebook right now where on some sites the show-faces option hides the actual login button. There is a bug-report that I found earlier on Facebook's bug-report page, but I can't seem to find it now.

Either way, if you disable the faces in your first snippet of code (changing the 2nd parameter to 'false'), it will fix the issue. Obviously then though, there's no faces, if that's what you want.

I'll try to look more for the bug report. If I can't find it, and you're still having issues, we'll re-submit it to them to hopefully get a fix from them. There's nothing we can do in JFBConnect to fix this, unfortunately.

Hope that helps explain,
Alex
The topic has been locked.
Support Specialist
11 years 3 months ago #29157 by alzander
Replied by alzander on topic Login button code?
Just noticed this line at the bottom of the Login button information page:

Note: If show-faces=true and the user is already logged in, no login button is shown.

developers.facebook.com/docs/reference/plugins/login/

I'm assuming that means if the user is already logged into Facebook and has approved your app. If that's the case, then that would mean that you'd need to have the 'automatically log facebook users in' option enabled if you want to use the show-faces option. Otherwise, the faces will be shown but the user won't be able to re-login after they've registered on your site.

Seems silly and incorrect, but that may be the new behavior of the button and that option. Should be easy to test by removing the application from the user's profile and see if the login button re-appears (since facebook doesn't think you've approved the app anymore).

Let me know if that makes sense.

Thanks,
Alex
The topic has been locked.
11 years 3 months ago #29171 by chramb1
Replied by chramb1 on topic Login button code?
Makes perfect sense. And I'll just not use faces - not important on the login UI at all.
The topic has been locked.
Support Specialist
11 years 3 months ago #29174 by alzander
Replied by alzander on topic Login button code?
Glad to hear it's not a big deal. Really don't think there's much we could have done anyway since, from that footnote on the Login plugin page, it's probably working as intended. :)

Alex
The topic has been locked.