Adding a CCK field from Content Profile to Author Pane

Last updated on
30 April 2025

Printing a field from the user's profile node on their author pane can be done but it's not simple and could have performance implications. The instructions are provided here for your convenience but the code is coming from Content Profile, not Author Pane.

  1. You will need to set up your module or theme to preprocess Author Pane. See http://drupal.org/node/326809 for an explanation. Make sure this runs after Content Profile.
  2. In your preprocess function, add: $FOO = $variables['content_profile']->get_variable('NODE_TYPE', 'field_FIELD_NAME'); where FOO is a variable name you choose, NODE_TYPE is the type of your node profile (if using APK, that will be "uprofile") and FIELD_NAME is the machine name of the field you are retrieving.
  3. $FOO will usually be an array. Depending on the field type, this can be structured differently. The easiest thing to do, assuming you have the Devel module installed, is to add dsm($FOO) to see what's in there.
  4. To add the field to the Author Pane template, use $variables['BAR'] = $FOO['0']['safe']; where that is adapted to the actual structure of the field array.

An example, using the "interests" field that comes with the APK profile node export:

  $interests_array = $variables['content_profile']->get_variable('uprofile', 'field_uprofile_interests');
  $variables['interests'] = $interests_array['0']['safe'];

You can then use <?php print $interests; ?> in your template file.

Help improve this page

Page status: Not set

You can: