You are here

function pathauto_user_update_alias in Pathauto 7

Same name and namespace in other branches
  1. 6.2 pathauto.module \pathauto_user_update_alias()
  2. 6 pathauto.module \pathauto_user_update_alias()

Update the URL aliases for an individual user account.

Parameters

$account: A user account object.

$op: Operation being performed on the account ('insert', 'update' or 'bulkupdate').

$options: An optional array of additional options.

4 calls to pathauto_user_update_alias()
pathauto_user_insert in ./pathauto.module
Implements hook_user_insert().
pathauto_user_update in ./pathauto.module
Implements hook_user_update().
pathauto_user_update_action in ./pathauto.module
Update action wrapper for pathauto_user_update_alias().
pathauto_user_update_alias_multiple in ./pathauto.module
Update the URL aliases for multiple user accounts.

File

./pathauto.module, line 1067
Main file for the Pathauto module, which automatically generates aliases for content.

Code

function pathauto_user_update_alias(stdClass $account, $op, array $options = array()) {

  // Skip processing if the user has disabled pathauto for the account.
  if (isset($account->path['pathauto']) && empty($account->path['pathauto']) && empty($options['force'])) {
    return FALSE;
  }
  $options += array(
    'alias blog' => module_exists('blog'),
    // $user->language is not the user entity language, thus we need to skip
    // the property fallback check.
    'language' => pathauto_entity_language('user', $account, FALSE),
  );

  // Skip processing if the account has no pattern.
  if (!pathauto_pattern_load_by_entity('user', '', $options['language'])) {
    return FALSE;
  }
  module_load_include('inc', 'pathauto');
  $uri = entity_uri('user', $account);
  $return = pathauto_create_alias('user', $op, $uri['path'], array(
    'user' => $account,
  ), NULL, $options['language']);

  // Because blogs are also associated with users, also generate the blog paths.
  if (!empty($options['alias blog'])) {
    pathauto_blog_update_alias($account, $op, $options);
  }
  return $return;
}