A module I'm working on is adding roles to users when that user creates a specific node type. My site uses the views module and I'm currently controlling access to several views, based on user roles. When a user gains a new role, their view access privileges do not update.

Example:
View 1 requires a role of 'example' to be viewed.
User A has no roles.
User A cannot access View 1.

User A creates node, which attaches a role of 'example.
User A has 'example' role (which has been verified).
User A cannot access View 1 (still).

I can remedy this by manually editing User A from the admin area. Making any changes to the user, or simply re-submitting the user from an edit screen does the trick.

I've tried:
- Refreshing the views cache.
- Rebuilding permissions on Post Settings.
- Logging the user out and logging back in.
- Running a user_save on the use object, after the role has been added.

None of these seem to fix it.

Comments

jbomb’s picture

did you updating the users_roles table manually?

node-add-matt’s picture

I've tried adding the role three different ways, all with the same results:
- Manually running query.
- Running the user_multiple_role_edit() function.
- Editing the $user object and running the user_save() function.

It doesn't seem to matter, they all work (for adding a role).

None, however, allow the user instant access to a View that requires that role.

Scott Reynolds’s picture

using any special caching stuff? Advcache module? APC? eAccelerator?

if you logout and log back in does ur view work?

node-add-matt’s picture

I don't have any non-standard cache modules installed. My browser cache is disabled.

As I mentioned (see above), logging out/in doesn't seem to have any effect.