Score:0

Submission query alter by entity ID

ru flag

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.

function event_registration_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {

  if ($view->id() == 'event_register') {
    $webform = \Drupal\webform\Entity\Webform::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?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.