Maybe i am just missing this; but wouldn't be pretty handy to have an api call provided to let me get the content profile info for a user.

Ideally, i guess if i did a user_load i would get the content_profile node content from that users content_profile nodes. But failing that, why not simply a content_profile_load($uid, $type) where type is either the cp cck type or "all" for all the user's cp info.

maybe my case is too extreme but seems pretty simple:

- i have a node with a user ref field
- i want to pull some info from the cp of the user referenced by that userref field

so, i have the user's uid, but dont see anyway to get at his cp data (short of just writing the sql myself)

Comments

andreiashu’s picture

Hi. There already is a function that does that (i'll paste it directly from cp): function content_profile_load($type, $uid, $lang = '') where $type is the content profile's type.

andreiashu’s picture

the function is at line 466 :)

andreiashu’s picture

Status: Active » Fixed

I think this issue is fixed. If one thinks not then reopen it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dealancer’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Component: Base module » Documentation
Status: Closed (fixed) » Needs work

Please document how to call this function on the module front page and README file. Now this function is on line 481

dealancer’s picture

Category: support » bug
dealancer’s picture

Title: no api to load user's content profile nodes » no api documentation to load user's content profile nodes
jjustman’s picture

It seems that type => 'all' does not work any more.

dbinoj’s picture

API documentation for this module would be great!!

mattcasey’s picture

content_profile_load() from most recent dev:

/**
 * Loads the node, like node_load but makes sure the results are cached.
 *
 * @param $type
 *   The content profile's type.
 * @param $uid
 *   The profile owner's user id.
 * @param $lang
 *   Optional. If translation is enabled, the language of the profile to return.
 * @param $reset
 *   Optional. If set, the cache is reset.
 */
function content_profile_load($type, $uid, $lang = '', $reset = NULL) {
  static $cache = array();

  if (!isset($cache[$type][$uid][$lang]) || $reset) {
    $cache[$type][$uid][$lang] = FALSE;
    $params = array('type' => $type, 'uid' => $uid);
    if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) {
      $cache[$type][$uid][$lang] = $node->nid;
    }
    return $node;
  }
  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
}