Score:0

Filtering webform submission results in a template file or in Views

tg flag

(Drupal 7) My situation is the following: I am using one single webform on my Drupal page that shows up on the page in different places for different events and gets a unique ID for each event to group results by. So when someone submits it to register for event A, the result will have ‘A’ as its event ID in the submission table; when someone registers for event B (on a different part of the page), the result gets saved with ‘B’ as its event ID etc.

I now would like to limit submissions per event, i.e. check the already submitted results for the webform to see how many submissions have been made with a certain ID already, so that I can the decide to either display the webform or a ‘limit reached’ message.

I’d be happy to either:

  1. check the submissions in PHP code in my template file where I display the webform and learn how to filter submission results so I can get the count for a certain event ID or
  2. get the submission results and filter them by ID for counting in a Drupal View so I can then make the view display the webform block or the message

Either is fine with me but so far I am stuck with both of these ideas. I do not know and couldn’t find out online so far how to access a given webform’s already submitted results in a PHP template file. And for the Views approach, I’ve installed Webform MySQL Views module hoping to get more options there but I couldn’t figure out how to get access to the indidual fields of the webform submissions; the ones that show up in the normal Webform submission tables.

In short, I am looking for a way to get the count for a webform’s submissions filtered by a field of those submissions. ‘Tell me how often this form has been submitted already with X as the value in the Y field.’

Any help would be greatly appreciated. Thank you.

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.