function user_uid_optional_to_arg

user_uid_optional_to_arg($arg)

Returns $arg or the user ID of the current user if $arg is '%' or empty.

@todo rethink the naming of this in Drupal 8.

File

modules/user/user.module, line 2027
Enables the user registration and login system.

Code

function user_uid_optional_to_arg($arg) {
  // Give back the current user uid when called from eg. tracker, aka.
  // with an empty arg. Also use the current user uid when called from
  // the menu with a % for the current account link.
  return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_uid_optional_to_arg/7.x