I have two content types, Location and Offer. The Offer type has an entity reference field that points to one or more Locations.

A user of my Merchant role may create Location and Offer nodes. When creating an offer, they need to select from the list of Location nodes that they created.

I created a view with an "Entity Reference Source" display to build the Merchant's list of Locations when creating Offers. I limited the Locations to this Merchant by a relationship between author (of the Location) and currently logged in user.

Now, I need Administrator users to be able to edit Offers. The problem is that the view creates a list of the Administrator's Locations instead of the author Merchant's Locations.

How can I supply a list of entities to the locations entity reference field that is the current user's Locations when an Offer is being created and the author's Locations when an Administrator edits?


2 Answers 2


You are probably looking for a way to pass a contextual filter from the current page to the entity selection view.

Currently an argument can sadly only be static.

However there is a patch that allows you to add an argument using a token provided by the current page you are on.

You can find the patch here: https://drupal.org/node/1699378#comment-6809760


You can use the Views Arguments module with the default argument callback. Your callback can return the argument exception value (typically the string all) which forces the view to skip the argument and return all results. This can be done when the current user is admin otherwise the current user id is returned.

Your Answer

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

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