Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPForms: new smart tag - current date and time
<?php
// Register the smart tag.
add_filter( 'wpforms_smart_tags', static function( $tags ) {
// Key is the tag, value is the tag name.
$tags['current_time'] = 'Current Date/Time';
return $tags;
} );
// Replace its value on form render on front-end.
add_filter( 'wpforms_process_smart_tags', static function( $field_val, $form_data ) {
return str_replace( '{current_time}', date_i18n( 'Y-m-d H:i:s' ), $field_val );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.