I've been trying to use CCK userreference to set up a field and a content type form where users can be chosen. My idea is to have a "meeting" content type, and "participants" would be a field where users participating in the meeting (from the ones registered in the site) can be chosen.
CCK userreference is showing the usernames, but I'd like the "real name" to be chosen. I've set up a field in the profile of each user showing the real name.
I've managed the real name to show in the "submitted by" tags by using the discussion in: http://drupal.org/node/147188
But this does not change the usernames in the CCK userreference field.
Does anybody know a way of achieving this?
* Walter Garcia-Fontes [20/06/07 16:58]:
I've been trying to use CCK userreference to set up a field and a content type form where users can be chosen. My idea is to have a "meeting" content type, and "participants" would be a field where users participating in the meeting (from the ones registered in the site) can be chosen.
CCK userreference is showing the usernames, but I'd like the "real name" to be chosen. I've set up a field in the profile of each user showing the real name.
I've managed the real name to show in the "submitted by" tags by using the discussion in: http://drupal.org/node/147188
But this does not change the usernames in the CCK userreference field.
Does anybody know a way of achieving this?
I finally hacked the CCK userreference module to achieve this. I created a name field (lastname, name) for the users in their profiles. Then I changed the references to the user tables to the profile tables in userreference.module.
At line 187: $items[$delta]['default user_name'] = db_result(db_query("SELECT value FROM {profile_values} WHERE uid = '%d'", $items[$delta]['uid']));
At line 265: if (empty($roles) || in_array(DRUPAL_AUTHENTICATED_RID, $roles)) { $result = db_query('SELECT u.value, u.uid FROM {profile_values} u WHERE uid > 0 ORDER BY u.value ASC'); } else { $result = db_query('SELECT u.value, u.uid FROM {profile_values} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE u.uid > 0 AND r.rid IN ('. implode($roles, ',') .') ORDER BY u.value ASC'); } else { $result = db_query('SELECT u.value, u.uid FROM {profile_values} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE u.uid > 0 AND r.rid IN ('. implode($roles, ',') .') ORDER BY u.value ASC'); }
$users = array(); while ($user = db_fetch_object($result)) { $users[$user->uid] = $user->value; } return $users; }
Now I get the real names in the userreference field created by CCK.