You are here

function hybridauth_user_view in HybridAuth Social Login 7.2

Implements hook_user_view().

File

./hybridauth.module, line 590
Main file for the HybridAuth module.

Code

function hybridauth_user_view($account, $view_mode, $langcode) {
  $identities = _hybridauth_identity_load_by_uid($account->uid);
  $providers = hybridauth_providers_list();
  $header = array(
    t('Authentication provider'),
    t('Identity'),
  );
  $rows = array();
  foreach ($identities as $identity) {
    $data = unserialize($identity['data']);
    $profile_link = '';
    if (!empty($data['profileURL'])) {
      $profile_link = l($data['profileURL'], $data['profileURL'], array(
        'attributes' => array(
          'target' => '_blank',
        ),
        'external' => TRUE,
      ));
    }
    $rows[] = array(
      $providers[$data['provider']],
      $profile_link,
    );
  }
  $account->content['hybridauth_identities'] = array(
    '#type' => 'item',
    '#title' => t('HybridAuth identities'),
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#sticky' => FALSE,
    '#empty' => t('There are no connected identities.'),
    // Adding the #name property so that our container has the 'form-item-hybridauth' class.
    // @see theme_form_element().
    '#name' => 'hybridauth',
  );
}