Home › Forums › Quform WordPress › Date verification (30 days back)
- This topic has 2 replies, 2 voices, and was last updated 11 years, 4 months ago by toppkarakter.
- AuthorPosts
- July 23, 2013 at 2:05 pm #5399toppkarakterParticipant
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;
}
July 24, 2013 at 11:51 am #5419AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 31, 2013 at 9:36 am #5547toppkarakterParticipantThis worked great! Thanks 🙂
- AuthorPosts
- You must be logged in to reply to this topic.