Plugin Author
Phil
(@philsbury)
Hi @ondway2legend,
This isn’t possible out of the box right now, but there’s possible options to make it happen with code. You could style the input boxes to look like a single field and enable the auto tab option. Maybe a bit ropey but would probably work.
An alternative would be to do some template overrides and custom javascript, here’s a basic example;
In the root of your theme, create a file: age-gate/partials/form/sections/inputs.php
Here you can override the default fields, you’ll still need the normal fields too, so that’s what is in the for loop:
<input type="date" class="my-age-gate-field" />
<?php foreach ($fields as $key => $field) : ?>
<input type="hidden" name="age_gate[<?php echo esc_attr($key) ?>]" required>
<?php endforeach; ?>
We’ll use the new date field to populate the hidden fields, for that we’ll need some javascript and to listen for the age_gate_shown event (could be done with jQuery on too); in your functions.php add
add_action( 'wp_footer', function() {
?>
<script>
window.addEventListener('age_gate_shown', function() {
document.querySelector('.my-age-gate-field').addEventListener('change', function(e) {
var parts = e.target.value.split('-');
document.querySelector('[name="age_gate[y]"]').value = parts[0];
document.querySelector('[name="age_gate[m]"]').value = parts[1];
document.querySelector('[name="age_gate[d]"]').value = parts[2];
});
});
</script>
<?php
});
And that’ll do it as a basic example, style up how you need
Thanks
Phil