I have a webform called Event Registration which has 3 fields: name, email and event(entity reference). I created a block view and I want to display the number of users registered to a certain event. I wanted to add contextual filters to the view but for some reason my custom fields are not displaying in the block, only global. I then attempted to alter the query but I have been unsuccessful in adding this condition to it.
Code:
function event_registration_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { if ($view->id() == 'event_register') { $webform = DrupalwebformEntityWebform::load('event_subscribe'); $node = Drupal::routeMatch()->getParameter("node")->id(); if ($webform->hasSubmissions()) { $query = Drupal::entityQuery('webform_submission') ->condition('webform_id', 'event_subscribe') ->condition('event', $node); $result = $query->accessCheck(FALSE)->execute();
What am I doing wrong?