Closed (outdated)
Project:
Field Permissions
Version:
7.x-1.0-beta2
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Feb 2012 at 15:12 UTC
Updated:
6 Feb 2025 at 21:06 UTC
Jump to comment: Most recent
Comments
Comment #1
marvix commentedany one for this ?!
Comment #2
marvix commentedfor anyone may need this ...
Comment #3
mxwitkowski commentedThis works quite well. Thanks.
Another idea: I have a use case where I want to show the field name but not the value to users without view permissions. The use case is for a site where premium content can be purchased. I want to set the view permission to block certain users, but let them know that a restricted field exists, then instead of showing the value display a message to the user providing additional information. Ideally, this message to the user would be managed via the admin UI.
Can this be done?
Comment #4
Zarevac commentedMarvix,
Where do you add this exactly?
Comment #5
jonathan_hunt commentedIt would be good to be able to add a custom "access denied" message in the field settings added by field_permissions. In the meantime, you can implement hook_node_view_alter() with per-field logic similar to:
Comment #6
Chimos commentedSorry,
where and how should we use this code?
Thanks !
Comment #7
marvix commentedYou can added in tempate.php under function THEME_preprocess_node , or you can just added some where in the tempate.php...
Comment #8
Chimos commentedThank you!
Comment #9
liliplanet commentedHi Jonathan, would you be so kind to guide me on where to add your hook_node_view_alter() at http://drupal.org/comment/reply/1429200/5835296 ?
Would most appreciate your help, thx
Comment #10
jonathan_hunt commentedThe code I suggested for hook_view_alter() would go in a custom module. You need to adapt the function name hook_view_alter() to suit the name of your custom module. See https://drupal.org/node/361112 and the nodeapi_example module from https://drupal.org/project/examples
Comment #11
liliplanet commentedthank you Jonathan, that is above my head .. I had a look and have to create a new module .. perhaps you have created an example please?
Comment #12
jonathan_hunt commentedI don't have ready code to show because I don't recall which site I used this on, and in any case the code would be incorporated with other customisations for that site. The examples I cited should be sufficient if you are a module developer (or want to become one). Otherwise you may need to hire one.
Comment #13
Paulset commentedHi,
I try the code of @jonathan_hunt (#5) for add a custom "access denied" message (in my template.php), but i have many errors...
Would there be another solution?
Comment #14
bluegeek9 commentedField Permissions does not support Drupal 7.