You are here

function party_user_get_party in Party 8.2

Same name and namespace in other branches
  1. 7 modules/party_user/party_user.module \party_user_get_party()

Get a User's Party

Parameters

mixed $user The user entity or uid:

Return value

Party a Party Object

6 calls to party_user_get_party()
party_hat_user_party_hat_ctools_access_check in modules/party_hat/plugins/access/user_party_hat.inc
Check for access.
party_simplenews_simplenews_subscriber_insert in modules/party_simplenews/party_simplenews.module
Implements hook_simplenews_subscriber_insert.
party_user_party_from_user_context in modules/party_user/plugins/relationships/party_from_user.inc
Return a new context based on an existing context.
party_user_username_alter in modules/party_user/party_user.module
Implements hook_username_alter().
party_user_user_update in modules/party_user/party_user.module
Implements hook_user_update().

... See full list

File

modules/party_user/party_user.module, line 371
Support for linking users to parties

Code

function party_user_get_party($user) {
  if (is_object($user)) {
    $user = $user->uid;
  }
  $result = db_select('party_attached_entity', 'pae')
    ->fields('pae', array(
    'pid',
  ))
    ->condition('eid', $user, '=')
    ->condition('data_set', 'user')
    ->execute()
    ->fetchCol();
  $party_id = reset($result);
  return party_load($party_id);
}