How to get value of Date field?

I need to get the values of the submitted field values to use in my own script. I have this working by doing this:

$post_data['Phone'] = rgar($entry, '5');

This works fine. However, I have a Date field (3 fields split up into DD MM YYYY). How can I get the value of this?

The name/id of the DD field is: name=“input_12[]” id=“input_16_12_2”

Im trying things like:

$post_data['DOB'] = rgar($entry, 'input_16_12_2') . "/" . input_16_12_3 . "/" . input_16_12_4;

but no success.

So how can I get the value of these Date fields?

It’s not the whole input_16_12_2 that’s being used for rgar(). If I’m not mistaken it should be used like this:

$post_data['DOB'] = rgar( $entry, '12.2' ) . "/" . rgar( $entry, '12.3' ) . "/" . rgar( $entry, '12.4' );

You can check what the contents of $entry (and through that get the correct names to use in rgar()) with this:

wp_die( '<pre>' . print_r( $entry, true ) . '</pre>' ); exit;

I usually use error_log (and remove the exit;) instead of wp_die btw, but for that you need to know where the logfiles of your hosting are stored.

1 Like

Or you can use the built in Gravity Forms logging to do the same thing. Just add this to your code (equivalent to the above):

GFCommon::log_debug( __METHOD__ . '(): $entry => ' . print_r( $entry, true ) );

1 Like