Hey, guys.
Here is what I HAVE:
--RULE--
EVENT: Content is Viewed
CONDITION: A field within the viewed content equals a certain value.
ACTION: Current user is given a certain role.
Because of this role, the user can now see certain fields within the content. This works to an extent. The page appears, and the user has the right role and can view the fields allowed by that role.
The PROBLEM: The page is already being viewed, so the only way the user can see the privileged fields is to REFRESH the browser.
(Note: The user's role may need to change from node to node, so I am essentially trying to change roles dynamically as the user views particular nodes of this certain content type.)
Here is what I NEED:
--RULE--
EVENT: Content is being LOADED/LOADING
CONDITION: A field within the content is examined to see if it contains a certain value
ACTION: Current user is given a certain role
THEN: The page is viewed with the privileged field already displayed. No need to refresh the browser.
Could you please offer suggestions as to how I might either fix my problem using rules (preferably) or a different approach to solving my issue?
I'm pretty sure there must be a smart way to go about this, but I'm really having a hard time finding it.
Ideas?
Comments
Why make the fields
Why make the fields conditional on role if you are going to simply grant the role when the page is viewed. It seems the end result is the fields are publicly viewable.
It's not quite that simple ...
Hi, Nevets.
On my node I can specify the names of users who should have access to certain fields.
For example, one user may have access to financial information-related fields.
Another user may have access to client information fields.
My rule checks for the user's name in certain fields and then grants them the appropriate role.
As I mentioned, it actually works according to my usage needs ... other than the page being rendered before the field is examined. This causes me to have to refresh.
Thank you.
Why not just grant the user
Why not just grant the user the appropriate role?
Wont' Work For Me
Just doesn't work that way in this use case.
I need a way to dynamically switch permissions from node to node. I appreciate the possible alternative ideas. If it were that simple, I would have done it. However, this is built on GCC (kind of like OG) and it just doesn't really allow for creating member roles with field-level permissions. This means I have to do it myself.
I need to figure out a way to switch roles on the fly.
Why aren't you just actually
Why aren't you just actually using Organic Groups? Just put all nodes that some particular user has to be able to see in a group (you could even make that very user the group) and grant the user the correct privileges. You can even use Rules and VBO to automatically create memberships based on some field values.
Besides, what you want to do doesn't sound good. Changing roles on the fly might bring you in some nasty messes quickly. Maybe you can explain your use case in more detail and we can recommend some other approach?
Had a hard time with Organic Groups
I actually did try that months ago. It was my original plan. However, I found working through all the bugs I encountered with Organic Groups exasperating, and so I switched to GCC.
GCC proved to be much less hassle, but it is definitely lacking in the permissions, views, and rules integration area.
At this point, I am so deep into building this app that I can't afford to go back to OG.
In truth, I really like GCC and would like to contribute to it's development in the future, as I get better at this.
Anyway, my dynamic permissions switching is working. But it certainly isn't optimal, and it was a design mistake I have created due to inexperience.
But here I am.
Similar Issue
I have similar issue. The issue I am facing is that when A creates a ticket to B, A should not be able to modify the ticket. Only B should be able to modify. I can have two role one for A and one for B with the appropriate permissions. But what if a ticket is created and assigned to A then he would not be able to make modifications to the ticket. In this case I have to change roles of the user on the fly. Can anyone suggest a way to solve this issue?
Thanks in Advance.
I did this with a combination
I did this with a combination of GCC, field permissions and rules.
As some above posters have said, it is messy and probably not a great approach
Thank you all for your input.
Thank you all for your input.
I would be interested in investing in the Drupal community by hiring someone to build a module that created a "Before Content Is Viewed" event for Rules.
Any advice on how to best move forward with that?
I posted a request on
I posted a request on Craigslist for a Drupal Developer to help me create a module for this. I've gotten several replies and a couple of them seem to be from legitimate Drupal Developers.
If I get this module made, it essentially will add something like a "Before Content is Viewed" Rule event.
I will pay for it and contribute it to the community. Hopefully it will help someone else.
For Any of You with Similar Issues
Well, my problem is solved. While I'm sure my approach to designing my Drupal web app was not optimal, it made more financial sense to patch it up than to re-build it.
I had hoped to contribute the module back to the Drupal community. However, the fix was too tied up into my code to make create a generalized module.
That said, my fix came from Allan and Brett over at Devetry.com. Within two days they built a custom module that allows my web app to dynamically alter user roles, and it works perfectly in conjunction with the GCC module I used to build my app.
I highly recommend giving back to the Drupal Community by helping out the caliber of developers they have there. These guys are making Drupal look good.
I have the same Issue
I am glad your issue is solved. It would be great if you could share the patch or the module you have used. I could look at it and try to implement that module in my Drupal website as well. Thanks.