Download & Extend

no api documentation to load user's content profile nodes

Project:Content Profile
Version:6.x-1.x-dev
Component:Documentation
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

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

#1

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.

#2

the function is at line 466 :)

#3

Status:active» fixed

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

#4

Status:fixed» closed (fixed)

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

#5

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

#6

Category:support request» bug report

#7

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

#8

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

#9

API documentation for this module would be great!!

#10

content_profile_load() from most recent dev:

<?php
/**
* 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;
}
?>
nobody click here