Date verification (30 days back)

Home Forums Quform WordPress Date verification (30 days back)

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5399
    toppkarakter
    Participant

    Hi

    Great plugin! I loved it so much that I had to purchase 2 licenses (probably more soon).

    I have used the “Age verification” function and it works great. Could this also be fixed to check if the date is more than 30 days back in time?

    We are using this form for people that want to cancel a 30 day trial service. When the order date(that they enter themselves) is above 30 days, I want the error message to appear.

    Added bonus is if the “Your trial has expired – above 30 days” could be conditional linked to a HTML form. Optional but would be awesome 🙂

    This is the code I use:
    add_filter('iphorm_element_valid_iphorm_2_5', 'mytheme_verify_age', 10, 3);

    function mytheme_verify_age($valid, $value, $element)
    {
    if ($valid) {
    $age = get_age("{$value['year']}-{$value['month']}-{$value['day']}");

    if ($age > 18) {
    $element->addError('You need to be over 18');
    $valid = false;
    }
    }

    return $valid;
    }

    // Get a person's age from date of birth
    function get_age($dob) {
    $adjust = (date("md") >= date("md", strtotime($dob))) ? 0 : -1;
    $years = date("Y") - date("Y", strtotime($dob));
    return $years + $adjust;
    }

    #5419
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #5547
    toppkarakter
    Participant

    This worked great! Thanks 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy