Views filter based on value in referenced entity I'm attempting to use a view to display the body of a content type that is referenced based on a field referencing another content type as long as that content type is referenced by another field. Confusing I know. Here's a diagram of what I'm trying to accomplish.



I need to display the body and title of all 'news' that reference a 'horse' that an 'owner' references as long as that 'owner' is referencing the current user.

I understand that there would be much better ways to structure my content type fields to get them to play more nicely, and I understand that I could easily accomplish this by not using views and making a custom module but that isn't an option available to me. I am required to use views. I wouldn't mind creating a custom views filter plugin, or use a hook though. I understand how to perform entity queries that can accomplish this task. However I'm not sure how view filter plugins work.

Is there a way to accomplish this specifically with views?
So assuming there's a content type with machine name new for News, owner for Owner, horse for horse. 

The news content type has a field named field_horses referencing horses

The owner content type has an instance of the same field field_horses and a 
reference field to User, field_user

Create a view listing Content of type News

Add a relationship

Entity Reference: Referenced Entity
A bridge to the Content entity that is referenced via field_horses

require this relationship

add a second relationship

Entity Reference: Referencing entity
A bridge to the Content entity that is referencing Content via field_horses

have this second one use the first relationship "Content Entity referenced from field_horses"

require this relationship

add a third relationship

Entity Reference: Referenced Entity
A bridge to the User entity that is referenced via field_user

have this third relationship use the second relationship "Content referencing content from field_horses"

require this relationship

For filters you need two content type filters
One for Content type = News, using no relationships
another for Content Type = Owner using the "Content referencing content from field_horses" relationship

One user filter, Current User (yes), using the "User entity referenced from field_user



$view = new view();
$view-&gt;name = 'news';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'node';
$view-&gt;human_name = 'News';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'News';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'perm';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'default';
$handler-&gt;display-&gt;display_options['row_plugin'] = 'fields';
/* Relationship: Entity Reference: Referenced Entity */
$handler-&gt;display-&gt;display_options['relationships']['field_horses_target_id']['id'] = 'field_horses_target_id';
$handler-&gt;display-&gt;display_options['relationships']['field_horses_target_id']['table'] = 'field_data_field_horses';
$handler-&gt;display-&gt;display_options['relationships']['field_horses_target_id']['field'] = 'field_horses_target_id';
$handler-&gt;display-&gt;display_options['relationships']['field_horses_target_id']['required'] = TRUE;
/* Relationship: Entity Reference: Referencing entity */
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_horses_node']['id'] = 'reverse_field_horses_node';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_horses_node']['table'] = 'node';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_horses_node']['field'] = 'reverse_field_horses_node';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_horses_node']['relationship'] = 'field_horses_target_id';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_horses_node']['required'] = TRUE;
/* Relationship: Entity Reference: Referenced Entity */
$handler-&gt;display-&gt;display_options['relationships']['field_user_target_id']['id'] = 'field_user_target_id';
$handler-&gt;display-&gt;display_options['relationships']['field_user_target_id']['table'] = 'field_data_field_user';
$handler-&gt;display-&gt;display_options['relationships']['field_user_target_id']['field'] = 'field_user_target_id';
$handler-&gt;display-&gt;display_options['relationships']['field_user_target_id']['relationship'] = 'reverse_field_horses_node';
$handler-&gt;display-&gt;display_options['relationships']['field_user_target_id']['required'] = TRUE;
/* Field: Content: Title */
$handler-&gt;display-&gt;display_options['fields']['title']['id'] = 'title';
$handler-&gt;display-&gt;display_options['fields']['title']['table'] = 'node';
$handler-&gt;display-&gt;display_options['fields']['title']['field'] = 'title';
$handler-&gt;display-&gt;display_options['fields']['title']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler-&gt;display-&gt;display_options['sorts']['created']['id'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['table'] = 'node';
$handler-&gt;display-&gt;display_options['sorts']['created']['field'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler-&gt;display-&gt;display_options['filters']['status']['id'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['status']['field'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['value'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['group'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler-&gt;display-&gt;display_options['filters']['type']['id'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['type']['field'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['value'] = array(
  'news' =&gt; 'news',
);
/* Filter criterion: Content: Type */
$handler-&gt;display-&gt;display_options['filters']['type_1']['id'] = 'type_1';
$handler-&gt;display-&gt;display_options['filters']['type_1']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['type_1']['field'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type_1']['relationship'] = 'reverse_field_horses_node';
$handler-&gt;display-&gt;display_options['filters']['type_1']['value'] = array(
  'owner' =&gt; 'owner',
);
/* Filter criterion: User: Current */
$handler-&gt;display-&gt;display_options['filters']['uid_current']['id'] = 'uid_current';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['table'] = 'users';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['field'] = 'uid_current';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['relationship'] = 'field_user_target_id';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['value'] = '1';

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['path'] = 'horse-news';