0

I created 2 new user fields for the user (object/entity) on my D7 site. Using views, I can select 'content' or 'user' for querying data. When I use views to query the 'user', the 2 new fields come up just fine. However, when I select 'content', the 2 new fields are not there. This makes sense to me since the 2 new fields are tied to the user entity.

For my purposes, I need both content AND user data. The strange or weird thing is, when I select 'content' for my base and use relationships to find and pull user entity fields, SOME old custom created fields already tied to the User Entity is present and I can select them, BUT my 2 new fields are not.

I tried clearing caches and making sure I had active content with the 2 new fields enabled. So why can I find in relationships, entity references to old custom fields, but not my new fields I created?

It feels like a catch 22. If I select user, I have my new fields, but not the content, and vice versa.

2
  • 2
    If you're starting with user view, add relationship of author content. If you're starting with content view and relationship of author. How did you got about creating these 2 new user fields? Did you do it through the UI? OR did you do it programmatically via custom module?
    – No Sssweat
    Commented May 17, 2019 at 13:35
  • I set the data through the field UI. I added author content like you said and now I can use the 2 new fields in my tables view. The field values are boolean and it doesn't display true or false, but I think I just have to mess with it. Thank you for your help.
    – Shawn
    Commented May 17, 2019 at 21:02

1 Answer 1

0

There is a Relationship that introduces "backwards" Entity reference info into the Views.

In Drupal 7 that is called something like this (you can find this in the list of Relationships in your Content Views under the Entity Reference Category):

Entity Reference: Referencing entity
A bridge to the User entity that is referencing Content via field_[myERfield]

After you have that you will be able to add the User: Name field, it will automatically use the above Relationship, and it will show which user referenced that particular node, for your each Views row.


In Drupal 8 the Relationship is called

User using field_[myERfield]
Relate each User with a field_[myERfield] set to the content.

The procedure is the same, you can now add Fields or Filters relating to User fields/data, if they're set to use the Relationship the user shown will be the one referencing the content of that Views row.

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.