Drupal 7 – Override the Facebook Connect login button theme

We can implement Facebook Login using Facebook Connect. For more info, please refer to
Drupal 7 – Allow Facebook login using Facebook Connect

For those who wants to override that Facebook Login template, add the following function in your theme template.php and and customize it as u wish.

function theme_fbconnect_login_button($variables) {
  $op = $variables['op'];
  $user_profile = $variables['user_profile'];
  $text = $variables['text'];
  $attr = $variables['attr'];
  if ($op == 'login') {
    $url = url('fbconnect/register/create');
    $title = t('Hello %name', array('%name' => $user_profile['name']));
    $desc = t('Login to this site using your Facebook credentials.');
    $link = '<a href="/fbconnect/register/create" class="fb_button fb_button_' . $attr['size'] . '"><span class="fb_button_text">' . $text . '</span></a>';
    $button = '<button onclick="location.href=\'' . $url . '\'" id="fblogin" type="button">Log in</button>';
    return '<h3>' . $title . '</h3>' . $desc . $link;
  }
  else {
    $attr['data-scope'] = "email";
    $button = '<fb:login-button ' . drupal_attributes($attr) . '>' . $text . '</fb:login-button>';
    return $button;
  }
}

 

Done =)

Reference: Drupal API Reference Help

About these ads

3 thoughts on “Drupal 7 – Override the Facebook Connect login button theme”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s