I've got FBconnect all set up and configured, but I was wondering if anyone knows how I can show or hide specific blocks using the 'PHP returns TRUE' option, based on whether or not the user is logged in using Facebook Connect.

I have a block that shows their user image to indicate that they are logged in. Currently it only shows for logged in users, but I want it to show for only users which are logged in with FB. I also have another block that is a Facebook Connect link that I want to show only when a user isn't logged in via Facebook, hopefully allowing an already logged in user to link their account without having to go through a logout-login with Facebook process.

Comments

arcane’s picture

Yes I would be interested to know this as well.

nevets’s picture

The function you want is fbconnect_get_fbuid(); Some variations on what you want

User is logged into Drupal and Facebook

$fbuid  = fbconnect_get_fbuid();

if ($fbuid && user_is_logged_in()) {
  return TRUE;
}
else {
  return FALSE;
}

User is logged into Facebook and Facebook account is associated with a Drupal account

$fbuid  = fbconnect_get_fbuid();

if ($fbuid && _is_fbconnect_user($fbuid)) {
  return TRUE;
}
else {
  return FALSE;
}

User is logged into Drupal and Facebook and Facebook account is associated with a Drupal account

$fbuid  = fbconnect_get_fbuid();

if ($fbuid  && user_is_logged_in() && _is_fbconnect_user($fbuid)) {
  return TRUE;
}
else {
  return FALSE;
}