Hello again with another question:

How to give/restrict to a specific role the permission to view a field of a node-type renderd in a view?

To explain: I have installed the field permissions module to restrict the visibility of a node field to registered users only. This works works fine when rendering/viewing the node directly (/node/xy)

In the next step I've built a view to show a list of those nodes in a table (node fields). In that view/table, the restricted field is visible and I can't find any section where to set the permissions for the individual field (only for the entire view, via access).

As always, any hint or help makes me happy

Best regards

Most helpful answers

Hello

There is a module field_permissions which restricts access on a field basis directly in your content type. Maybe you want give it a try.

https://backdropcms.org/project/field_permissions 

On the drupal page there is a screenshot of the field settings:

https://www.drupal.org/files/images/field_permissions.jpg

greetings

Conni

Comments

Does the View itself need to be viewable by non-registered users? If not, you can just change the access settings for the view itself, and hide it from anonymous users.

Hello argiepaino,

thank you for picking up this topic.

Yes, I want/need to show the view, with the complete table head and all rows. Only the values of one colum (field) should be hidden.

Best regards

Hi again.

I found a Drupal 9/10 module which seems to cover me needs
https://www.drupal.org/project/views_field_permissions

Unfortunately porting a module is far beyond the scope of my capabilities. Hopefully someone else will adopt this.

In the meanwhile, I solved my purpose with a workaround, maybe somebody will find it interesting or helpfull: I

– added another field to the node type and kept it blank/empty on all nodes 
– cloned the view display, added the "empty" field and removed the filled one 
– granted different permissions to these displays
– put both displays into the layout and set visibility options to show only one of them, according to the role/permission.

Best regards

Hello Conni,

thank you for picking up this.

I checked the mention module again... and yes, it does work on views as well (didn't realized this before), but if visibility for a specific field is restricted, then in a table display the full column is hidden, including the first row (table head), which in my case should be visible (even if the corresponding data is hidden).

Best regards