在选择列表(CCK)中填充用户名

时间:2014-02-10 11:27:56

标签: drupal drupal-7

如何在选择列表中填充用户名。我在允许列表文本框中添加了以下代码。但是选择列表显示PHP代码而不是用户名。

global $user;
$sql = "SELECT name FROM  users";
$res = db_query($sql);
while($row = db_fetch_array($res)){
$rows[] = $row['name'];
}
return $rows;

enter image description here

注意:应用程序在D7中运行。 我也按照以下步骤进行操作。

Enable Core module PHP Filter.
Set/Check user permissions: admin/people/permissions#module-php.
Set/Check Text Formats: admin/config/content/formats.
Enable CCK Module. This step is often overlooked. However without CCK Module enabled you wont be able to enter (and thus execute) PHP-code in the Allowed-Values-List window

1 个答案:

答案 0 :(得分:1)

您可能想尝试实体参考 - 它适用于CCK并允许您引用用户:https://drupal.org/project/entityreference