You are here

hybridauth.module in HybridAuth Social Login 7

Same filename and directory in other branches
  1. 6.2 hybridauth.module
  2. 7.2 hybridauth.module

File

hybridauth.module
View source
<?php

define('HYBRIDAUTH_MINIMUM_PHP', '5.2.0');
define('HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_WRAPPER_TITLE_DEFAULT', 'Or log in with...');
define('HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_STYLE_DEFAULT', 'list');
define('HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_ICON_SIZE_DEFAULT', '64');
define('HYBRIDAUTH_WIDGET_USE_OVERLAY_DEFAULT', TRUE);
define('HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_LINK_TITLE_DEFAULT', 'Social networking account');
define('HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_LINK_ALT_DEFAULT', '');

/**
 * Implements hook_permission().
 */
function hybridauth_permission() {
  $permissions = array(
    'administer hybridauth' => array(
      'title' => t('Administer HybridAuth settings'),
      'restrict access' => TRUE,
    ),
    'manage own identities' => array(
      'title' => t('Manage own 3rd party identities'),
      'description' => t('Add and delete own 3rd party identities on the HybridAuth tab in the user profile.'),
    ),
  );
  return $permissions;
}

/**
 * Implements hook_menu().
 */
function hybridauth_menu() {
  $items = array();
  $items['admin/config/people/hybridauth'] = array(
    'title' => 'HybridAuth settings',
    'description' => 'Provides HybridAuth social sign-on',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'hybridauth_admin_settings',
    ),
    'file' => 'hybridauth.admin.inc',
    'access arguments' => array(
      'administer hybridauth',
    ),
  );
  $items['admin/config/people/hybridauth/providers'] = array(
    'title' => 'Providers',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/config/people/hybridauth/profile'] = array(
    'title' => 'Profile',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'hybridauth_admin_profile_settings',
    ),
    'file' => 'hybridauth.admin.inc',
    'access arguments' => array(
      'administer hybridauth',
    ),
  );
  $items['admin/config/people/hybridauth/widget'] = array(
    'title' => 'Widget',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'hybridauth_admin_widget_settings',
    ),
    'file' => 'hybridauth.admin.inc',
    'access arguments' => array(
      'administer hybridauth',
    ),
  );
  $items['admin/config/people/hybridauth/provider/%'] = array(
    'title callback' => 'hybridauth_admin_format_provider_title',
    'title arguments' => array(
      5,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'hybridauth_admin_provider_settings',
      5,
    ),
    'file' => 'hybridauth.admin.inc',
    'access arguments' => array(
      'administer hybridauth',
    ),
  );
  $items['hybridauth/endpoint'] = array(
    'page callback' => 'hybridauth_endpoint',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'hybridauth.pages.inc',
  );
  $items['hybridauth/popup'] = array(
    'page callback' => 'hybridauth_popup',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'hybridauth.pages.inc',
  );
  $items['hybridauth/popup/openid'] = array(
    'page callback' => 'hybridauth_popup_openid',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'hybridauth.pages.inc',
  );
  $items['hybridauth/confirm/%/%/%'] = array(
    'title' => 'Confirm email',
    'page callback' => 'hybridauth_email_confirm',
    'page arguments' => array(
      2,
      3,
      4,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'hybridauth.pages.inc',
  );
  $items['user/%user/hybridauth'] = array(
    'title' => 'Linked Accounts',
    'page callback' => 'hybridauth_user_identities',
    'page arguments' => array(
      1,
    ),
    'access callback' => '_hybridauth_own_identities_access',
    'access arguments' => array(
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'hybridauth.pages.inc',
  );
  $items['user/%user/hybridauth/delete'] = array(
    'title' => 'Delete Linked Account',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'hybridauth_user_delete_form',
      1,
    ),
    'access callback' => '_hybridauth_own_identities_access',
    'access arguments' => array(
      1,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'hybridauth.pages.inc',
  );
  return $items;
}

/**
 * Display a text format form title.
 */
function hybridauth_admin_format_provider_title($provider_id) {
  module_load_include('inc', 'hybridauth', 'hybridauth.auth');
  return hybridauth_get_provider_name($provider_id);
}

/**
 * Menu item access callback - users should be allowed to 'manage own
 * identities' and edit user data for the account.
 */
function _hybridauth_own_identities_access($account) {
  return user_access('manage own identities') && user_edit_access($account);
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hybridauth_form_user_login_block_alter(&$form, &$form_state) {
  if (variable_get('hybridauth_widget_attach_loginform', FALSE)) {
    _hybridauth_widget_user_login_form_alter($form, $form_state);
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hybridauth_form_user_login_alter(&$form, &$form_state) {
  if (variable_get('hybridauth_widget_attach_loginform', FALSE)) {
    _hybridauth_widget_user_login_form_alter($form, $form_state);
  }
}

/**
 * Adds Engage sign-in link to the form.
 */
function _hybridauth_widget_user_login_form_alter(&$form, &$form_state) {
  $style = variable_get('hybridauth_widget_attach_loginform_style', HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_STYLE_DEFAULT);
  $form['hybridauth_widget_wrapper'] = array(
    '#type' => 'fieldset',
    '#title' => variable_get('hybridauth_widget_attach_loginform_wrapper_title', HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_WRAPPER_TITLE_DEFAULT),
    'hybridauth_widget_wrapper' => array(
      '#theme' => 'hybridauth_widget',
      '#style' => $style,
      '#size' => variable_get('hybridauth_widget_attach_loginform_icon_size', HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_ICON_SIZE_DEFAULT),
      '#weight' => variable_get('hybridauth_widget_attach_loginform_weight', 150),
    ),
  );
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Prefills the registration form with values acquired via HybridAuth.
 */
function hybridauth_form_user_register_form_alter(&$form, &$form_state) {

  // Only alter if the user is signing in using HybridAuth (the HybridAuth session may
  // still be set if admin has signed in using HybridAuth and is adding a user, so
  // check that this is not the case).
  if (!isset($_SESSION) || !isset($_SESSION['hybridauth']) || $_SESSION['hybridauth']['stat'] != 'ok' || user_access('administer users')) {
    return;
  }
  $profile = $_SESSION['hybridauth']['profile'];

  // Use the nickname returned by HybridAuth.
  $form['account']['name']['#default_value'] = $profile['displayName'];
  $mail = '';
  if (!empty($profile['email'])) {
    $mail = $profile['email'];
  }

  // Use the email returned by HybridAuth, if any.
  $form['account']['mail']['#default_value'] = $mail;

  // If email verification is not required, hide the password field and
  // just fill with random password to avoid confusion.
  if (!empty($profile['emailVerified']) || !variable_get('user_email_verification', TRUE) || variable_get('hybridauth_bypass_email_verification', FALSE)) {
    $form['account']['pass']['#type'] = 'hidden';
    $form['account']['pass']['#value'] = user_password();
  }
  $form['hybridauth_id'] = array(
    '#type' => 'value',
    '#default_value' => $profile['identifier'],
  );
  $form['id_display'] = array(
    '#type' => 'item',
    '#weight' => 10,
    '#title' => t('Your account ID'),
    '#description' => t('This @provider account will be linked to your site account after registration.', array(
      '@provider' => $_SESSION['hybridauth_provider_info']['name'],
    )),
    '#markup' => check_plain(_hybridauth_encode_authname($_SESSION['hybridauth_provider_info']['id'], $profile['identifier'])),
  );

  // replace the default user_register form submit handler with our own (because
  // we need to honor verifiedEmail and hybridauth_bypass_email_verification, save the
  // HybridAuth user picture, etc.)
  $form['#submit'][array_search('user_register_submit', $form['#submit'])] = 'hybridauth_user_register_submit';

  /*
  $field_map = variable_get('hybridauth_profile_fields_map', array());
  if (empty($field_map)) {
    return;
  }

  // Use HybridAuth data to pre-fill profile fields.
  if(module_exists('profile')) {
    // Build an array of HybridAuth field ID's keyed by profile field name
    $map = array();
    foreach ($field_map as $mid => $field_mapping) {
      // Make sure it's a valid mapping.
      if (!isset($field_mapping['fid'])) {
        continue;
      }

      if($field_mapping['set'] == 'profile') {
        $map[$field_mapping['field']] = $field_mapping['fid'];
      }
    }
    // Search for profile fields and initialize them with HybridAuth profile data.
    if(!empty($map)) {
      foreach ($form as $category_key => $category) {
        if (is_array($category)) {
          foreach ($category as $field_key => $field) {
            if (substr($field_key, 0, 8) == 'profile_' && isset($map[$field_key])) {
              $form[$category_key][$field_key]['#default_value'] = _hybridauth_data_map($_SESSION['hybridauth'], $map[$field_key]);
            }
          }
        }
      }
    }
  }

  // Use HybridAuth data to pre-fill Profile2 fields.
  if(module_exists('profile2')) {
    // Build a map keyed by $bundle.$field (we cannot key by $field, as
    // fields in different bundles can have the same name).
    $map = array();
    foreach ($field_map as $mid => $field_mapping) {
      // Make sure it's a valid mapping.
      if (!isset($field_mapping['fid'])) {
        continue;
      }

      if($field_mapping['set'] == 'profile2') {
        $map[$field_mapping['bundle'] . $field_mapping['field']] = $field_mapping['fid'];
      }
    }
    if(!empty($map)) {
      foreach (field_info_instances('profile2') as $bundle => $fields) {
        foreach ($fields as $field => $array) {
          if (isset($map[$bundle.$field]) && $mapped_value = _hybridauth_data_map($_SESSION['hybridauth'], $map[$bundle.$field])) {
            $form['profile_' . $bundle][$field][LANGUAGE_NONE][0]['value']['#default_value'] = $mapped_value;
          }
        }
      }
    }
  }

  // Use HybridAuth data to pre-fill User fields.
  $map = array();
  foreach ($field_map as $mid => $field_mapping) {
    // Make sure it's a valid mapping.
    if (!isset($field_mapping['fid'])) {
      continue;
    }

    if($field_mapping['set'] == 'user') {
      $map[$field_mapping['field']] = $field_mapping['fid'];
    }
  }
  if(!empty($map)) {
    foreach (field_info_instances('user') as $bundle => $fields) {
      foreach ($fields as $field => $array) {
        if (isset($map[$field]) && $mapped_value = _hybridauth_data_map($_SESSION['hybridauth'], $map[$field])) {
          $form[$field][LANGUAGE_NONE][0]['value']['#default_value'] = $mapped_value;
        }
      }
    }
  }
  */
}

/**
 * Populates a given account's data with $profile from HybridAuth
 */
function _hybridauth_populate_user_record(&$account, $payload) {
  $edit['data'] = array(
    'hybridauth_data' => $payload,
  );
  return user_save($account, $edit);
}

/**
 * Downloads user picture from the 3rd party and links it to the user account.
 *
 * Returns user account.
 */
function _hybridauth_save_profile_picture(&$account) {

  // Should we bother?
  if (!variable_get('hybridauth_profile_import_photo', FALSE) || !variable_get('user_pictures', 0) || !isset($account->data['hybridauth_data']['profile']['photoURL'])) {
    return $account;
  }
  $photo_url = $account->data['hybridauth_data']['profile']['photoURL'];

  // We need to have the file locally
  $tmp_photo = drupal_tempnam('temporary://', 'drupal_hybridauth-');
  $tmp_photo_realpath = drupal_realpath($tmp_photo);
  copy($photo_url, $tmp_photo_realpath);

  // We'll need a file object to work with the file
  $info = image_get_info($tmp_photo_realpath);
  $file = new stdClass();
  $file->uid = $account->uid;
  $file->status = 0;

  // mark the file as temporary
  $file->filename = basename($tmp_photo_realpath);
  $file->uri = $tmp_photo;
  $file->filemime = $info['mime_type'];
  $file->filesize = $info['file_size'];

  // The file should be an image
  $errors = array();
  $errors += file_validate_is_image($file);
  $errors += file_validate_image_resolution($file, variable_get('user_picture_dimensions', '85x85'));
  $errors += file_validate_size($file, variable_get('user_picture_file_size', '30') * 1024);

  // Make sure file extension is a valid image
  if (!in_array(strtolower($info['extension']), array(
    'jpg',
    'png',
    'gif',
  ))) {
    $errors[] = ' invalid image file extension.';
  }
  if (count($errors)) {
    drupal_set_message(t('Profile Image Import:') . ' ' . $errors[0], 'warning');

    // Clean up (set fid to avoid error messages)
    $file->fid = 0;
    file_delete($file);
  }
  else {

    // We'll need a valid file id on the file object; file_save() will give us one
    $file = file_save($file);

    // Update user account (fid is not empty, status is temporary -- image
    // will be moved to proper directory and assigned to the user)
    $fields['picture'] = $file;
    $account = user_save($account, $fields);
  }
  return $account;
}

/**
 * Custom submit handler for the standard user_register form.
 */
function hybridauth_user_register_submit($form, &$form_state) {
  form_state_values_clean($form_state);
  $pass = user_password();
  $form_state['values']['pass'] = $pass;
  $form_state['values']['init'] = $form_state['values']['mail'];
  $account = $form['#user'];
  $category = $form['#user_category'];
  $account_unchanged = clone $account;
  entity_form_submit_build_entity('user', $account, $form, $form_state);
  $edit = array_intersect_key((array) $account, $form_state['values']);
  $account = user_save($account_unchanged, $edit, $category);

  // Add the HybridAuth data to the account.
  $account = _hybridauth_populate_user_record($account, $_SESSION['hybridauth']);

  // Terminate if an error occurred during user_save().
  if (!$account) {
    drupal_set_message(t("Error saving user account."), 'error');
    $form_state['redirect'] = '';
    return;
  }

  // Add the 3rd party profile picture to the account.
  $account = _hybridauth_save_profile_picture($account);
  watchdog('hybridauth', 'New user: %name (%email).', array(
    '%name' => $form_state['values']['name'],
    '%email' => $form_state['values']['mail'],
  ), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit'));
  $form_state['user'] = $account;
  $form_state['values']['uid'] = $account->uid;

  // Add plain text password into user account to generate mail tokens.
  $account->password = $pass;

  // If no email verification required, log the user in immediately.
  if ((!variable_get('user_email_verification', TRUE) || variable_get('hybridauth_bypass_email_verification', FALSE) || !empty($_SESSION['hybridauth']['profile']['verifiedEmail']) && strtolower($account->mail) == strtolower($_SESSION['hybridauth']['profile']['verifiedEmail'])) && $account->status) {
    _user_mail_notify('register_no_approval_required', $account);
    $form_state['uid'] = $account->uid;
    user_login_submit(array(), $form_state);
    drupal_set_message(t('Registration successful. You are now logged in.'));
  }
  elseif ($account->status) {

    // Require email confirmation
    drupal_mail('hybridauth', 'hybridauth_confirm_email', $account->mail, user_preferred_language($account), array(
      'account' => $account,
    ));
    drupal_set_message(t('In order to confirm your email address, an email has been sent to you with confirmation instructions.'));
  }
  else {
    _user_mail_notify('register_pending_approval', $account);
    drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
  }
  $form_state['redirect'] = '';
}

/**
 * Implements hook_user_insert().
 */
function hybridauth_user_insert(&$edit, $account, $category) {

  // Make sure user has registered via HybridAuth.
  if (!isset($_SESSION['hybridauth'])) {
    return;
  }
  $provider_id = $_SESSION['hybridauth_provider_info']['id'];
  $provider_name = $_SESSION['hybridauth_provider_info']['name'];
  $profile = $_SESSION['hybridauth']['profile'];

  // Since we are inserting in two tables (authmap and hybridauth_account),
  // use a transaction.
  $txn = db_transaction();
  try {
    user_set_authmaps($account, array(
      'authname_hybridauth' => _hybridauth_encode_authname($provider_id, $profile['identifier']),
    ));

    // Get the new authmap ID and insert it in the hybridauth_account table
    $aid = db_query('SELECT aid FROM {authmap} WHERE authname = :id', array(
      'id' => _hybridauth_encode_authname($provider_id, $profile['identifier']),
    ))
      ->fetchField();
    db_insert('hybridauth_account')
      ->fields(array(
      'aid' => $aid,
      'provider_id' => $provider_id,
      'created' => REQUEST_TIME,
    ))
      ->execute();
  } catch (Exception $e) {
    $txn
      ->rollback();
    watchdog_exception('hybridauth', $e);
  }
}

/**
 * Helper function: deletes all data created by this module for a user.
 *
 * @param integer $uid
 *   uid of the user that is being deleted.
 */
function _hybridauth_delete_user_data($uid) {
  $aids = db_select('authmap')
    ->fields('authmap', array(
    'aid',
  ))
    ->condition('uid', $uid);
  db_delete('hybridauth_account')
    ->condition('aid', $aids, 'IN')
    ->execute();
}

/**
 * Implements hook_user_delete().
 */
function hybridauth_user_delete($account) {
  _hybridauth_delete_user_data($account->uid);
}

/**
 * Implements hook_user_cancel().
 */
function hybridauth_user_cancel($edit, $account, $method) {
  switch ($method) {
    case 'user_cancel_reassign':
      _hybridauth_delete_user_data($account->uid);
      break;
  }
}

/**
 * Implements hook_mail().
 */
function hybridauth_mail($key, &$message, $params) {
  $language = $message['language'];
  $variables = array(
    'user' => $params['account'],
  );
  switch ($key) {
    case 'hybridauth_confirm_email':
      $message['subject'] = _hybridauth_mail_text($key . '_subject', $language, $variables);
      $message['body'][] = str_replace('user/reset', 'hybridauth/confirm', _hybridauth_mail_text($key . '_body', $language, $variables));
      break;
  }
}

/**
 * Returns a mail string for hybridauth_confirm_email_*.
 *
 * Used by hybridauth_core_mail() and the settings forms to retrieve mail strings.
 */
function _hybridauth_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
  $langcode = isset($language) ? $language->language : NULL;
  if ($admin_setting = variable_get('hybridauth_mail_' . $key, FALSE)) {

    // An admin setting overrides the default string.
    $text = $admin_setting;
  }
  else {

    // No override, return default string.
    switch ($key) {
      case 'hybridauth_confirm_email_subject':
        $text = t('Confirm your account at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'hybridauth_confirm_email_body':
        $text = t("[user:name],\n\nThank you for registering at [site:name].\n\nTo confirm your email address, click on this link or copy and paste it in your browser:\n\n[user:one-time-login-url]\n\nAfter confirming your email address, you will be able to log in to [site:name] using your new account.\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
    }
  }
  if ($replace) {
    return token_replace($text, $variables, array(
      'language' => $language,
      'callback' => 'user_mail_tokens',
    ));
  }
  return $text;
}
function _hybridauth_add_widget_css() {
  $done =& drupal_static(__FUNCTION__, FALSE);
  if (!$done) {
    drupal_add_css(drupal_get_path('module', 'hybridauth') . '/hybridauth.widget.css');
  }
}
function _hybridauth_add_icon_css() {
  $done =& drupal_static(__FUNCTION__, FALSE);
  if (!$done) {
    drupal_add_css(drupal_get_path('module', 'hybridauth') . '/hybridauth.icons.css');
  }
}

/**
 * Implements hook_theme().
 */
function hybridauth_theme($existing, $type, $theme, $path) {
  return array(
    'hybridauth_admin_settings' => array(
      'render element' => 'form',
      'file' => 'hybridauth.admin.inc',
    ),
    'hybridauth_widget' => array(
      'variables' => array(
        'style' => HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_STYLE_DEFAULT,
        'size' => HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_ICON_SIZE_DEFAULT,
      ),
      'template' => 'hybridauth-widget',
      'file' => 'hybridauth.widget.inc',
    ),
    'hybridauth_popup_loading' => array(
      'variables' => array(
        'provider_id' => NULL,
        'done' => FALSE,
        'overlay' => FALSE,
      ),
      'template' => 'hybridauth-popup-loading',
      'file' => 'hybridauth.widget.inc',
    ),
    'hybridauth_popup_list' => array(
      'variables' => array(
        'overlay' => FALSE,
      ),
      'template' => 'hybridauth-popup-list',
      'file' => 'hybridauth.widget.inc',
    ),
    'hybridauth_popup_provider' => array(
      'variables' => array(
        'provider_id' => NULL,
        'overlay' => FALSE,
      ),
      'template' => 'hybridauth-popup-provider',
      'file' => 'hybridauth.widget.inc',
    ),
    'hybridauth_provider_icon' => array(
      'variables' => array(
        'size' => HYBRIDAUTH_WIDGET_ATTACH_LOGINFORM_ICON_SIZE_DEFAULT,
        'provider_id' => NULL,
      ),
    ),
  );
}

/**
 * Returns markup for a specific provider icon.
 *
 * An image sprite with all Engage provider icons is included in the images
 * directory for custom theming purposes.
 */
function theme_hybridauth_provider_icon($vars) {
  module_load_include('inc', 'hybridauth', 'hybridauth.auth');
  $size = $vars['size'];
  $provider_id = $vars['provider_id'];
  $provider_name = hybridauth_get_provider_name($provider_id);
  $style = array(
    drupal_html_class('hybridauth-icon'),
    drupal_html_class('hybridauth-icon-' . $size),
    drupal_html_class('hybridauth-' . $provider_id),
    drupal_html_class('hybridauth-' . $provider_id . '-' . $size),
  );
  _hybridauth_add_icon_css();
  return '<span' . drupal_attributes(array(
    'class' => $style,
    'id' => drupal_html_id('hybridauth-' . $provider_id),
    'title' => $provider_name,
  )) . '></span>';
}

/**
 * Creates an authname that will remain unique across providers
 */
function _hybridauth_encode_authname($provider_id, $identifier) {
  switch ($provider_id) {
    case 'Facebook':
      if (is_numeric($identifier)) {
        return 'http://www.facebook.com/profile.php?id=' . $identifier;
      }
      return $identifier;
    case 'Twitter':
      if (is_numeric($identifier)) {
        return 'http://twitter.com/account/profile?user_id=' . $identifier;
      }
      return $identifier;
    case 'Google':
      if (is_numeric($identifier)) {
        return 'https://www.google.com/profiles/' . $identifier;
      }
      return $identifier;
    default:
      return $identifier;
  }
}

/**
 * Changes an authname back into the provider identifier format
 */
function _hybridauth_decode_authname($provider_id, $authname) {
  switch ($provider_id) {
    case 'Facebook':
      return str_replace('http://www.facebook.com/profile.php?id=', '', $authname);
    case 'Twitter':
      return str_replace('http://twitter.com/account/profile?user_id=', '', $authname);
    case 'Google':
      return str_replace('https://www.google.com/profiles/', '', $authname);
    default:
      return $authname;
  }
}

Functions

Namesort descending Description
hybridauth_admin_format_provider_title Display a text format form title.
hybridauth_form_user_login_alter Implements hook_form_FORM_ID_alter().
hybridauth_form_user_login_block_alter Implements hook_form_FORM_ID_alter().
hybridauth_form_user_register_form_alter Implements hook_form_FORM_ID_alter().
hybridauth_mail Implements hook_mail().
hybridauth_menu Implements hook_menu().
hybridauth_permission Implements hook_permission().
hybridauth_theme Implements hook_theme().
hybridauth_user_cancel Implements hook_user_cancel().
hybridauth_user_delete Implements hook_user_delete().
hybridauth_user_insert Implements hook_user_insert().
hybridauth_user_register_submit Custom submit handler for the standard user_register form.
theme_hybridauth_provider_icon Returns markup for a specific provider icon.
_hybridauth_add_icon_css
_hybridauth_add_widget_css
_hybridauth_decode_authname Changes an authname back into the provider identifier format
_hybridauth_delete_user_data Helper function: deletes all data created by this module for a user.
_hybridauth_encode_authname Creates an authname that will remain unique across providers
_hybridauth_mail_text Returns a mail string for hybridauth_confirm_email_*.
_hybridauth_own_identities_access Menu item access callback - users should be allowed to 'manage own identities' and edit user data for the account.
_hybridauth_populate_user_record Populates a given account's data with $profile from HybridAuth
_hybridauth_save_profile_picture Downloads user picture from the 3rd party and links it to the user account.
_hybridauth_widget_user_login_form_alter Adds Engage sign-in link to the form.

Constants