Forums

Check date and close form after specific date

Kwalitijd 04 Apr, 2015
Hi, I would like to check the current date before showing a form. The form should expire on a specific date and show an notification like 'Subscription closed'. Can this be done?
Thanks in advance!
GreyHead 04 Apr, 2015
Answer
1 Likes
Hi Kwalitijd,

Yes, you can do this. Add an Event Switcher from the Validation Actions group in the beginning of the form On Load event. Open the settings and, in the Events box replace success,fail with closed. Save and Close the Event Switcher, re-open it and click the Load Events button. When you Save and Close again you should now have just an On closed event.

In the Code box add something like this:
<?php
if  (time() > strtotime("05/15/2015 4:00PM") ) {
    return 'closed';
}
?>

Then in the On Closed box you can redirect to a different page with a message. Here's one way of doing that with another Custom Code action:
<?php
$app = JFactory::getApplication();
$app->enqueueMessage('Sorry, we&squo;re closed');
$app->redirect('index.php');
?>

Bob
Kwalitijd 05 Apr, 2015
Thanks! That does the trick
This topic is locked and no more replies can be posted.