ashostak
Forum Replies Created
-
Forum: Plugins
In reply to: [Age Gate] Redirect failures to custom page based on field (like province)I believe to be almost there —
(1) I am specifying a “cookie” as the “data-message” attribute of each option, for instance with Quebec:
[ 'age' => false, 'name' => 'Quebec', 'cookie' => 'qb' ]Which gets included in each option as so:
$fields .= '<option id="ag-province" <strong>data-message="'. $province['cookie'] .'"</strong> value="'. base64_encode(base64_encode($province['age'])) .'">'. $province['name'] .'</option>'(2) Then I am creating a cookie called “age_gate_province” with the value based on the selected province field:
if (e.target.options[e.target.selectedIndex].dataset.message) { let cookie = e.target.options[e.target.selectedIndex].dataset.message; createCookie('age_gate_province', cookie, 30); }(A sample function of the createCookie function can be found here: https://www.quirksmode.org/js/cookies.html)
(3) Then I am reading the set cookie in the PHP templates to determine what content gets served up:
@if(isset($_COOKIE['age_gate_province'])) @if($_COOKIE['age_gate_province'] === 'qb') ... @endif @endif(4) Then under Age Gate > Restrictions, I am setting the option for “Redirect failures” to go to a general template that serves up different templates based on the province cookie.
…
The only thing I need help figuring out is how to get it to honour the ‘age’ value being set to ‘false’ (rather than a specific age value) to consider this to be an unsuccessful attempt and send it to this Sorry page?
Forum: Plugins
In reply to: [Age Gate] Restrict users from a selected province to enterThis worked perfectly, thank you very much Phil.
Do you have a donation link setup as I’d love to make a contribution for all your work on this.All the best,
Art