1

I have two content types, Restaurant and Lunch.

Restaurant content is created by content admins, and can be viewed by anyone.

Lunch has an entity reference field that references nodes of type Restaurant.

Logged in users need to be able to create their own Lunch content, but only see their own Restaurant in the referenced node select list.

Content admins can also create Lunch content, but they need to see all available Restaurants in the select list.

I'm thinking I need to put a user reference field to the Restaurant content type, and then I could filter a reference view by the referenced user? But here is where I get stuck, how then will content admins be able to see all Restaurants in the select list?

2

1 Answer 1

1

I found this solution that works:

Permissions (for a given content-type) Administrator & Staff - Edit ANY content Normal Member - Edit OWN content

Views Contextual Filter - Content: Author UID

WHEN THE FILTER VALUE IS NOT AVAILABLE - Provide default value: Type - "User ID from Logged in User"

WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED - Specify validation criteria: Validator - "USER" - Type of user filter value to allow - "Only allow numeric UIDs" - Restrict user based on role: Restrict to the selected roles - SELECT the role who can only edit his own content - Action to take if filter value does not validate - "Display All Results for the specified data" [important]

The last step (marked important), makes all the data (view results) available to other users, who have access to edit any content.

See https://www.drupal.org/node/2317525

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.