You are here

function hybridauth_token_values in HybridAuth Social Login 6.2

Implements hook_token_values().

File

./hybridauth.tokens.inc, line 31
Builds placeholder replacement tokens for HybridAuth-related data.

Code

function hybridauth_token_values($type, $object = NULL, $options = array()) {
  global $hybridauth_data;
  $values = array();
  if ($type == 'user') {
    if (!empty($hybridauth_data)) {

      //for just created user
      $data = $hybridauth_data;
    }
    elseif (!empty($object->hybridauth)) {

      //for existing user
      $data = $object->hybridauth;
    }
    if (!empty($data)) {
      foreach (hybridauth_fields_list() as $key => $value) {
        $values['hybridauth_' . $key] = $data[$key];
      }
    }
  }
  if ($type == 'hybridauth') {
    $data = $object;
    if (!empty($data)) {
      foreach (hybridauth_fields_list() as $key => $value) {
        $values[$key] = $data[$key];
      }
    }
  }
  return $values;
}