You are here

function user_get_statistics_field_value in Better Statistics 7

Returns the stats field value for a given field.

Parameters

string $field: The name of the field for which a value should be returned.

Return value

mixed The value of the stats field specified, or NULL if none could be found.

See also

user_better_statistics_fields()

1 string reference to 'user_get_statistics_field_value'
user_better_statistics_fields in modules/user.statistics.inc
Implements hook_better_statistics_fields().

File

modules/user.statistics.inc, line 216
Statistics API functions and hooks for the User module.

Code

function user_get_statistics_field_value($field) {
  $user = function_exists('menu_get_object') ? menu_get_object('user') : NULL;
  switch ($field) {
    case 'current_user_id':
      return isset($GLOBALS['user']->uid) ? $GLOBALS['user']->uid : NULL;
      break;
    case 'current_user_name':
      return isset($GLOBALS['user']->name) ? $GLOBALS['user']->name : NULL;
      break;
    case 'current_user_mail':
      return isset($GLOBALS['user']->mail) ? $GLOBALS['user']->mail : NULL;
      break;
    case 'page_user_id':
      return isset($user->uid) ? $user->uid : NULL;
      break;
    case 'page_user_name':
      return isset($user->name) ? $user->name : NULL;
      break;
    case 'page_user_mail':
      return isset($user->mail) ? $user->mail : NULL;
      break;
  }
  return NULL;
}