You are here

function services_remove_user_data in Services 7.3

Same name and namespace in other branches
  1. 6.3 services.module \services_remove_user_data()

Helper function to remove data from the user object.

Parameters

$account: Object user object.

5 calls to services_remove_user_data()
services_resource_build_index_list in ./services.module
Helper function to build a list of items satisfying the index query.
_system_resource_connect in resources/system_resource.inc
Returns the details of currently logged in user.
_user_resource_login in resources/user_resource.inc
Login a user using the specified credentials.
_user_resource_retrieve in resources/user_resource.inc
Get user details.
_user_resource_update in resources/user_resource.inc
Update an existing user.

File

./services.module, line 1014
Provides a generic but powerful API for web services.

Code

function services_remove_user_data(&$account) {
  global $user;

  // Remove the user password from the account object.
  unset($account->pass);
  if (isset($account->current_pass)) {
    unset($account->current_pass);
  }

  // Remove the user mail, if current user don't have "administer users"
  // permission, and the requested account not match the current user.
  if (!user_access('administer users') && isset($account->uid) && isset($user->uid) && $account->uid !== $user->uid) {
    unset($account->mail);
  }

  // Remove the user init, if current user don't have "administer users"
  // permission.
  if (!user_access('administer users')) {
    unset($account->init);
  }
  drupal_alter('services_account_object', $account);

  // Add the full URL to the user picture, if one is present.
  if (variable_get('user_pictures', FALSE) && isset($account->picture->uri)) {
    $account->picture->url = file_create_url($account->picture->uri);
  }
}