function redhen_contact_load_by_user in RedHen CRM 7
Load a contact record from a user account.
Parameters
object $account: User object.
int $state: Redhen state. Defaults to active.
Return value
mixed Contact or FALSE if not found.
12 calls to redhen_contact_load_by_user()
- redhen_contact_form_user_profile_form_alter in modules/
redhen_contact/ redhen_contact.module - Implements hook_form_FORM_ID_alter().
- redhen_contact_load_by_user_callback in modules/
redhen_contact/ redhen_contact.module - Wrapper around redhen_contact_load_by_user to use as user property callback.
- redhen_contact_preprocess_comment in modules/
redhen_contact/ redhen_contact.module - Implements theme_preprocess_comment().
- redhen_contact_username_alter in modules/
redhen_contact/ redhen_contact.module - Implements hook_username_alter().
- redhen_contact_user_cancel in modules/
redhen_contact/ redhen_contact.module - Implements hook_user_cancel().
File
- modules/
redhen_contact/ redhen_contact.module, line 1065 - Module file for RedHen contacts.
Code
function redhen_contact_load_by_user($account, $state = REDHEN_STATE_ACTIVE) {
$contact =& drupal_static(__FUNCTION__ . $account->uid, FALSE);
if (!$contact && !empty($account->uid)) {
$contacts = redhen_contact_load_multiple(FALSE, array(
'uid' => $account->uid,
'redhen_state' => $state,
));
if (!empty($contacts)) {
// There should always be only a single active user linked to an account.
$contact = reset($contacts);
}
}
return $contact;
}