Views access not updating immediately.

node-add-matt - May 9, 2008 - 21:04

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.

did you updating the

jbomb - May 9, 2008 - 21:07

did you updating the users_roles table manually?

I've tried adding the role

node-add-matt - May 9, 2008 - 21:11

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.

using any special caching

Scott Reynolds - May 9, 2008 - 21:23

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

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

I don't have any

node-add-matt - May 12, 2008 - 13:23

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.

 
 

Drupal is a registered trademark of Dries Buytaert.