I am so close to resolving this. I could really, really use some help.
The $account->roles basically returns an array of roles that the user has.
I am trying to augment this array with additional roles that I add according to the group the user belongs to. Let's assume, for the moment, that I can return the array of roles I desire. In what format should they be in in order to slot into this user_access function command to replace $account->roles?:
$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys($account->roles)));
If, for example, my function to return roles is user_all_roles($user), how should the return array be formatted in order to work, i.e.:
$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys(user_all_roles($account))));
<./code>
This isn't working because, I assume, of the way I'm formatting the resulting array. Right now, I just return a basic array with two values:
0 = anonymous user role
4 = my custom role (this is the correct rid and it is in the roles and permissions tables)
However, my tests of user_access('permission') reveal that the roles, in the array format I am supplying, aren't being recognized. Any suggestions whatsoever? Thanks!