Hey everyone,

The site:
I am setting up a directory (sort of) site where I will have free and premium listings. The premium listings have extra fields like video, a gmap, image gallery, etc). To gain access to change a listing from free to premium, the user has to subscribe (via ubercart) and their role is upgraded.

My problem:
When the users subscription runs out, their role gets downgraded to a normal user and they can no longer edit their 'premium' fields on their listing, but they will still display.

Is their a way to make certain fields viewable by all but only if the author has the premium role? If they loose their role, the premium fields wont be viewable by anyone (still modifiable by admin though of course).

Comments

droople’s picture

Hello I have smilar needs but am still on 5x

http://drupal.org/node/388828

http://drupal.org/node/389152

Please share any updates. Also which module are you using for role subscription?

Thank you

that0n3guy’s picture

I am going to use ubercart for the subscription with authorize.net as my payment processor since I want recurring fee's. It can also be done pretty easily with civicrm, but recurring fee's only really works with standard paypal in 2.2.

As for hiding the fields, I'm just going to have it coded into the theme... I have someone working on this now.

toddwoof’s picture

We are doing something similar, except we're using CiviCRM to manage the membership payment part, synced with a Drupal role "Member."

But I think the Drupal question is the same: If someone drops out of the Member role (in our case because their Civi membership expires, so when the sync runs the user is removed from the Member role), we want the premium fields for that user's posts not to show.

So the goal, I think, is field-level visibility (for any user) based on the author's current role. Anyone have any suggestions?

greenbeans’s picture

Anyone seen a solution to this?

mattiasj’s picture

I just bumped into this problem while creating nodes with accessories for vehicles. Various roles shall be able to download different product sheets, so I want to control permissions based on role for a unique field.

krisgraham’s picture

I implemented something similar, and what I did was create a super-cck type with all the features, and a role check in node-yourContentType.tpl.php to limit the fields displayed based on role, corresponding to a role check in a proprietary module to limit fields displayed. This allows content to upgrade and downgrade seamlessly based on role. Though I have hit a big wall in trying to figure out how to sell multiple nodes with this method.

karens’s picture

Category: support » feature

I think the best route forward to make field permissions easier to set up would be to use http://drupal.org/project/permissions_api, then write some wrapper code to do some of these custom things using that API.

This could be a separate contrib module or a patch to the core module that would work if the Permissions API is installed. If someone wants to create such a thing, that would be great. I suspect none of the CCK maintainers has time to do this.

markus_petrux’s picture

Status: Active » Closed (won't fix)

This is already possible since the $node is passed to hook_field_access() as implemented in #514452: Add new argument $node to content_access() to enhance the context for hook_field_access()

I'm marking this issue as won't fix because something like this dould be implemented in contrib. Now, it is possible. ;-)

Example modules that take advantage of the $node argument in hook_field_access():

http://drupal.org/project/field_permissions
http://drupal.org/project/cck_private_fields