There is a option to set maximum date and minimum date in custom user attribute in hivepress but only absolute values are accepted. I want to create a filter so that maximum date that can be set to ‘dob’ attribute of user = (current date - 18) .
I want to add age restriction so that only users need to be over 16.
i tried this code but didnt work:
add_filter('hivepress/v1/models/user_attributes', function($attributes) {
// Find the user attribute with field name 'dob'
foreach ($attributes as &$attribute) {
if ($attribute['field'] === 'dob') {
// Set the minimum and maximum dates for the 'dob' field
$attribute['min_date'] = '1935-01-01'; // Minimum date: January 1, 1935
$attribute['max_date'] = date('Y-m-d', strtotime('-18 years')); // Maximum date: 18 years before today
}
}
return $attributes;
});