0
votes

So here's the situation and I cannot figure out how to accomplish it.

I have a content type called "Alert". Each instance of this content type needs to have a webform (really just a submit button with hidden fields), that users click to acknowledge they have read and understand the alert. Ideally once submitted, the form should be replaced with a message along the lines of "You have marked this alert as read."

I do have a webform created (displaying as a block to be able to place within the variant page set up for the Alert type) and can get it to appear on each instance, but users can submit multiple times on each alert (submissions are set to unlimited as if i set it to 1 submission per user, the form does not render after the first submission on any alert). Additionally, once they click on one instance of the form, every additional instance will result in a message stating they have already submitted the form.

So I really have two issues. First, and most importanlty, allow a single submission per node (without the "already submitted" notice). Second, not required but would be nice, once it has been submitted for a specific node, the form no longer renders on that node for that particular user. Anyone have any ideas on the best way to accomplish these two aspects?

I'm running on Drupal 7.56, using the AT_Panels_Everywhere theme, Webform module Version: 7.x-4.15.

1
Are the users anonymous or logged in users?? - Sanjok Gurung
Yep. If you have logged users add some field to user profile to mark is user clicked already or not. If no, use the cookie to store that info. - MilanG
@Sanjok they would be logged in (authenticated role). - D Nielsen
@MilanG The issue with that is that the webform would be submitted multiple times, but would need to be limited to once per node per user. Unless I am misunderstanding your suggestion. - D Nielsen
Just a though , create a new table and name it whatever you want and have at least three fields in it like , nid, uid, visited(bool). Once the user clicks the button you can save the nid value, uid value and set True or 1 as a visited value. Next time you load the webform node you can do a query and check whether that uid has visited that node before and disable or hide the form if the visited value is true. - Sanjok Gurung

1 Answers

0
votes

In drupal 7, with webform 7.x-4.0, you can enable webforms within a content type. To do so:

Go to Structure > Content Types [Respective content type] > Edit In the bottom left section, find the Webforms Tab and choose Enable webforms for this content type.

Based on your use case, I'd recommend enabling that and installing the node clone module. Then you can make one alert node, setup the webform, limited to one submission per user and allow content managers to clone content. That node can serve as a template.