• Resolved pimmeelhuysen

    (@pimmeelhuysen)


    Hi there,

    Is there a way to let the date dropdown start with the date of today?

    Hope you can help.

    Thanks.

    Pim

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pimmeelhuysen

    (@pimmeelhuysen)

    Anyone? Need help with this.

    Plugin Author Phil

    (@philsbury)

    Hi @pimmeelhuysen,

    This is not an option currently within the plugin. You could use some javascript to make it work though.

    Here is an example assuming the use of the javascript mode:

    add_action('wp_footer', function () {
        ?>
        <script>
            window.addEventListener('agegateshown', function(){
                var date = new Date;
                var day = date.getDate().toString().padStart(2, 0); // day
                var month = (date.getMonth() + 1).toString().padStart(2, 0); // starts at 0
                var year = date.getFullYear();
    
                var daySelect = document.getElementById('age-gate-d');
                var monthSelect = document.getElementById('age-gate-m');
                var yearSelect = document.getElementById('age-gate-y');
    
                daySelect.value = day;
                monthSelect.value = month;
                yearSelect.value = year;
            });
        </script>
        <?php
    });

    Thanks
    Phil

    Thread Starter pimmeelhuysen

    (@pimmeelhuysen)

    Phil,

    Really, really awesome, it works!

    Thank you!

    Pim

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Start date with today’ is closed to new replies.