You are here

function profile2_by_uid_load in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_by_uid_load()

Menu load callback.

Returns the profile object for the given user. If there is none yet, a new object is created.

2 calls to profile2_by_uid_load()
profile2_delete_access in ./profile2.module
Determines whether the given user has access to delete a profile.
profile2_page_menu_local_tasks_alter in contrib/profile2_page.module
Implements hook_menu_local_tasks_alter().

File

./profile2.module, line 1210
Support for configurable user profiles.

Code

function profile2_by_uid_load($uid, $type_name) {
  if ($uid && is_numeric($uid) && ($account = user_load($uid))) {
    $profile = profile2_load_by_user($account, $type_name);
    if (!$profile) {
      $profile = profile2_create(array(
        'type' => $type_name,
      ));
      $profile
        ->setUser($account);
      $profile->is_new = TRUE;
    }
    return $profile;
  }
  return FALSE;
}