We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Consent question hide after submitted

How Do I?

Wessel's avatar
Wessel
32 posts
3 years ago
Wessel's avatar Wessel

Hi all,

How to define, that if visitor has submitted the form once, it won’t show up again? If i use sample code, it wil keep showing on the page.

There should be something by default like “if consent_submitted” or something, hope you’ll understand me. The alert functionality is only after submitting, so after reloading, or navigate to other page, i cannot use that function.

Thanks a lot!

{exp:consent:form}
 
   {consents}
   
  
     <fieldset>
       <dl>
         <dt>{consent_title}</dt>
         <dd>{consent_request}</dd>
       </dl>
       <label>
         <input type="radio" name="{consent_short_name}" value="y" {if consent_granted}checked{/if}>
         Toestaan
       </label>
       <label>
         <input type="radio" name="{consent_short_name}" value="n" {if ! consent_granted}checked{/if}>
         Weigeren
       </label>
     </fieldset>
   {/consents}

   <fieldset>
     <input type="submit" name="submit" value="Save">
   </fieldset>




{/exp:consent:form}
       
Chris's avatar
Chris
2 posts
3 years ago
Chris's avatar Chris

You need to wrap your form in a conditional tag like the below:

{exp:consent:requests consent="your-consent-name"}
{if consent_granted == 1}
{!-- do nothing because they have already consented --}
{if:else}
{exp:consent:form consent="your-consent-name" return="{current_url}/"}
{!-- your fields here --}
{/exp:consent:form}
{/if}
{/exp:consent:requests}
       
Wessel's avatar
Wessel
32 posts
3 years ago
Wessel's avatar Wessel

Hi Chris,

But when I have 3 consents… and they granted for 2 but declined 1… then it still show up with that option. There isn’t an ‘override’ tag that reminds if the consent form was submitted?

Thanks for quick response!

       
Chris's avatar
Chris
2 posts
3 years ago
Chris's avatar Chris

This sounds like what you’re looking for: [https://docs.expressionengine.com/latest/templates/globals/consent.html#checking-if-the-user-has-responded]

       
Wessel's avatar
Wessel
32 posts
3 years ago
Wessel's avatar Wessel

Hi Chris,

Looks like it works like it should! Thanks a lot, for others. This is the code i’ve used:

{if ! consent:has_responded:ee:cookies_performance}
<div>
<div>Cookies</div>
{exp:consent:form} {consents} <input checked="checked" name="{consent_short_name}" type="hidden" value="y" /> {/consents} <input name="submit" type="submit" value="Alles toestaan" /> <a href="#collapseCookie"> Zelf beheren </a> {/exp:consent:form}
<div>{exp:consent:form}
<div>{consents}
<div>
<div><strong>{consent_title}</strong></div>
<label> <input checked="checked" name="{consent_short_name}" type="radio" value="y" /> Toestaan </label> <label> <input checked="checked" name="{consent_short_name}" type="radio" value="n" /> Weigeren </label></div>
{/consents}</div>
<input name="submit" type="submit" value="Opslaan" /> {/exp:consent:form}</div>
</div>
{/if}
👍 1
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.