You are here

function example_user in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_upgrade/tests/old/samples/example.module \example_user()

Implementation of hook_user().

The $user parameter was renamed to $account in 4.7. The "form" and "register" operations have been removed. Use hook_form_alter instead.

File

coder_upgrade/tests/old/samples/example.module, line 1886

Code

function example_user($op, &$edit, &$user, $category = NULL) {
  if ($op == 'delete') {
    db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid);
    db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid);
  }
  elseif ($op == 'form' && $category == 'account') {
    $form['comment_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Comment settings'),
      '#collapsible' => TRUE,
      '#weight' => 4,
    );
    $form['comment_settings']['signature'] = array(
      '#type' => 'textarea',
      '#title' => t('Signature'),
      '#default_value' => $edit['signature'],
      '#description' => t('Your signature will be publicly displayed at the end of your comments.'),
    );
    return $form;
  }
  else {

    // Why would we have an ELSE in this situation?
    db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid);
    db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid);
  }
  switch ($op_test) {
    case 'after_update':

      // The user object has been updated and changed. Use this if (probably along with 'insert') if you want to reuse some information from the user object.
      // This block becomes example_
      break;
  }
  switch ($op) {
    case 'after_update':

      // The user object has been updated and changed. Use this if (probably along with 'insert') if you want to reuse some information from the user object.
      // This block becomes example_
      break;
    case 'categories':

      // A set of user information categories is requested.
      // This block becomes example_
      break;
    case 'delete':

      // The user account is being deleted. The module should remove its custom additions to the user object from the database.
      // This block becomes example_
      break;
    case 'form':

      // The user account edit form is about to be displayed. The module should present the form elements it wishes to inject into the form.
      // This block becomes example_
      break;
    case 'insert':

      // The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
      // This block becomes example_
      break;
    case 'load':

      // The user account is being loaded. The module may respond to this and insert additional information into the user object.
      // This block becomes example_
      break;
    case 'login':

      // The user just logged in.
      // This block becomes example_
      break;
    case 'logout':

      // The user just logged out.
      // This block becomes example_
      break;
    case 'register':

      // The user account registration form is about to be displayed. The module should present the form elements it wishes to inject into the form.
      // This block becomes example_
      break;
    case 'submit':

      // Modify the account before it gets saved.
      // This block becomes example_
      break;
    case 'update':

      // The user account is being changed. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
      // This block becomes example_
      break;
    case 'validate':

      // The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary.
      // This block becomes example_
      break;
    case 'view':

      // The user's account information is being displayed. The module should format its custom additions for display, and add them to the $account->content array.
      // This block becomes example_
      break;
  }
}