Handling list-select field in profile with computed fields module

samirb - March 14, 2008 - 18:04

I have created a list of colleges so that on registration the users can choose what college they're from. Now when they submit an article I'm trying to used "Computed Fields" module to add what college the post refers to (the user's college). However, I can't get it to work. Here is the code I've put in the computed fields module.

global $user;
$node_field[0]['value'] = $user->profile_college;

Any help would be great.

I haven't tested this but I

barrysampson - March 15, 2008 - 21:14

I haven't tested this but I think it should be:

global $user;
$node_field[0]['value'] = $user->profile_college[0]['value'];

Update

samirb - March 27, 2008 - 03:36

I kept playing around with the code and finally got it working. Here's the code:

// Load author details
$author = user_load(array('uid' => $node->uid));
$node_field[0]['value'] = $author->profile_college;

 
 

Drupal is a registered trademark of Dries Buytaert.