Hi Hans
I have just tried this out and got it working.
Firstly make sure you have set the field to a date field.
When you enter a date using the format 31-12-1943 it is translated to the format December 31, 1943 within the database. Therefore you should use the filter of
[pdb_list filter=”DOB<31-12-1943″].
It works for me. Of course you can also use
[pdb_list filter=”date_of_birth<December 31, 1943″]
I have found the Participants Database to be a fantastic plugin but it has very specific formatting options that you need to follow. Just practice and perserverance really.
Cheers
Thread Starter
hansbl
(@hansbl)
Hi Supernova24,
Thanks for your reaction.
I managed to get it working with:
function test_lqo_callback($query) {
if (is_page(‘senior’)) {
$query->clear_field_filter(‘dob’);
$birthyear = date(“Y”) – 75;
$reference = ‘dec 31, ‘ .$birthyear;
$query->add_filter(‘dob’, ‘<‘, $reference, ‘OR’);
$query->add_filter(‘dob_partner’, ‘<‘, $reference);
}
}
This seems to work.
I will try your solution.
Regards,
Hans
Thread Starter
hansbl
(@hansbl)
Hi Supernova24,
I am trying your solution but something odd is going on.
In the dashboard of WP the DOB is a datefield but in de database it is a bigint(20) with a number. For instance dob 16-02-1958 (d-m-y) is -374720400.
Probably that is why it is going wrong.
Do you know what causes this?
Thanks for your time and interest.
Regards,
Hans
That is how dates are stored: as what’s known as a Unix timestamp. That number represents the date, which is converted to a localized date string when displayed.
They are very easy to work with if you let PHP do the math.
For instance if you wanted to show a list of all the records with DOB > 75 years, you could do it like this:
<?php
// this is today's date 75 years ago
$cutoff_date = date( 'M j, Y', strtotime( '-75 years' ) );
// use that date to build the list filter
echo do_shortcode( '[pdb_list filter="dob<' . $cutoff_date . '|dob_partner<' . $cutoff_date . '"]' );
?>
Thread Starter
hansbl
(@hansbl)
OK, great.
Thanks for your quick reaction.
Regards,
Hans
Thread Starter
hansbl
(@hansbl)
Just one other question.
Where do I change the fontsize or color in the list depending on the dob?
Thanks in advance for your answer.
Regards,
Hans
To change the font size or color based on the value will require a custom template with some php code and custom CSS, there isn’t any way to do this with CSS alone.
One approach would be set a class name on the element wrapper based on the value, then use a CSS rule to give the value some special formatting.
Thread Starter
hansbl
(@hansbl)
Thanks for your answer.
It’s clear.
Regards,
Hans