You are here

function votingapi_current_user_identifier in Voting API 7.2

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

Generate a proper identifier for the current user: if they have an account, return their UID. Otherwise, return their IP address hash.

1 call to votingapi_current_user_identifier()
votingapi_set_votes in ./votingapi.module
Cast a vote on a particular piece of content.

File

./votingapi.module, line 241
A generalized voting API for Drupal.

Code

function votingapi_current_user_identifier() {
  global $user;
  $criteria = array(
    'uid' => $user->uid,
  );
  if (!$user->uid) {
    $criteria['vote_source'] = hash('sha256', serialize(ip_address()));
  }
  return $criteria;
}