Hi.
In "Allowed values" -> "PHP code", how can I use user info?
For example:

==============

$query = "SELECT rid FROM users_roles WHERE uid = ".$user->uid;
$result = db_query($query);
while ($row = db_fetch_array($result)) {
$rid[] = $row['rid'];
}
return $rid;

==============

My problem is that $user->uid is empty...
Thanks.

Comments

_

If you want the uid of the currently logged in user, you need to use global $user; first.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Ow, yes... soso ok... My

Ow, yes... soso ok...
My problem now is with the query... Do I need to put some code before query? I think that I don't have open connect to it.
Thanks.

db_query uses the active

db_query uses the active connection, there is no need to open one.

Also, a more Drupal approach to

$query = "SELECT rid FROM users_roles WHERE uid = ".$user->uid;
$result = db_query($query);

would be
$query = "SELECT rid FROM users_roles WHERE uid = %d";
$result = db_query($query, $user->uid);

Note you really do not need the query as $user->roles already contains the information. If you are using this for a CCK, type integer with a select widget you can simplify the PHP to

global $user;
return $user->roles;

I have not tried it but there is also the Role Reference module for CCK.

Ok... with this I see my

Ok... with this I see my authorized roles... but I need the content types that I have permission to access (to edit)... how can I return this?

If $user is suppose to refer

If $user is suppose to refer to the current user you need a global $user; otherwise $user is undefined.

nobody click here