You are here

function realname_user in Real Name 6

Same name and namespace in other branches
  1. 5 realname.module \realname_user()

Implements hook_user().

File

./realname.module, line 390

Code

function realname_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'load':
      $account->realname = realname_make_name($account);

      // If theme then replace name with realname.
      if (variable_get('realname_theme', TRUE) && $account->realname) {

        // Store it for places where it needed.
        if (!isset($account->realname_save) && is_object($account)) {
          $account->realname_save = $account->name;
        }
      }
      break;
    case 'delete':
      db_query("DELETE FROM {realname} WHERE uid = %d", $account->uid);
      break;
    case 'insert':
    case 'after_update':
      if ($module = variable_get('realname_profile_module', NULL)) {
        $module_info = realname_supported_modules($module);
        if (isset($module_info['cache']) && !$module_info['cache']) {
          return;
        }
      }
      $account->realname = _realname_make_name($account);

      // If we delete it first, then drupal_write_record is always an insert.
      db_query("DELETE FROM {realname} WHERE uid = %d", $account->uid);
      drupal_write_record('realname', $account);
  }
}