Preopulating date field

Hi all,

I have a date field created using an ACF date picker which is set up as user meta for date of birth.

Using the Gravity Forms User Registration add-on/update user, I’m trying to auto populate a gravity form date field with the corresponding dd/mm/yyyy data. Is there a way to do this using something like {user:date_of_birth:dd} {user:date_of_birth:mm} {user:date_of_birth:yyyy} or something like that?

We need to allow users to view and edit their date of birth in case it was originally entered incorrectly.



I’ve used the following before to dynamically populate ACF date from post meta into a field…

// Dynamically populate date from ACF-formatted post meta
add_filter( 'gform_field_value_acf_date', function ( $value ) {

    $date = get_post_meta( get_the_ID(), 'acf_date', true );

    return ( DateTime::createFromFormat( 'Ymd', $date ) )->format('m/d/Y');

} );

This could be updated to pull instead from current user meta. This uses the hook method for Dynamically Populating a Field, so you will also need to set the Advanced → Parameter Name accordingly in order to have the date populate a field.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.