• Resolved hansbl

    (@hansbl)


    Hello,

    Thanks for this great plugin.
    I am trying te get a list of records with people older then 75 and I am using the following:

    filter=”dob<current_year-75″

    But this does not seem to work

    filter=”dob<dec 31, 1943″

    Also does not work.

    Do you have a solution.

    Thanks in advance for the answer.

    Regards,
    Hans

Viewing 9 replies - 1 through 9 (of 9 total)
  • supernova42

    (@supernova42)

    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

    Plugin Author xnau webdesign

    (@xnau)

    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

    Plugin Author xnau webdesign

    (@xnau)

    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

    Thread Starter hansbl

    (@hansbl)

    Topic closed

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filter with date’ is closed to new replies.