Score:0

How to filter list items values based on user roles programmatically

td flag

I am in scenario where I need to filter list elements based on User Roles.

for example.. i have create two roles 1.Vegetable seller and 2. Fruits seller. I have created a list field with values as 'Apples','Mango','Potato','onion'.

Condition is that vegetable seller can only select vegetables(Potato and Onions) not fruits(Apples,Mango).

There are many list fields in our website. This is became a bottleneck for me.

I have seen Field_permission modules and Rules module but non of them worked.

and I am trying to implement using custom module. Any idea is welcomed. Thanks for reading.

(or) I am have an idea. please do let me even it is possible or not.. In Field settings of list field, I want to implement a section called "permissions". In "permissions" I want to create a form with two fields. One field with key or label and second field with Roles(may be in drop down form). but i dont know how to implement it and no idea of which hook function to use...So please help me.

misterdidi avatar
de flag
If still possible, maybe you could switch from list field to taxonomies and use https://www.drupal.org/project/permissions_by_term. It seems to achieve what you are looking for.
kankari avinash avatar
td flag
Hello, I have tried your method it is working but is not suitable for my websites because we have many listfield elements (they are more than 500 list elements). it is not possible to create all taxonomy terms. if you have any other alternatives, please do let me know. But thank you for your answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.