La manera recomendada de hacerlo es usando smart tags.
Existen instrucciones de como implementar smart tags personalizados donde puedes incluir ciertos elementos dinamicos para incluir. Siguiendo el ejemplo, puede ser algo como este codigo (se agrega en el archivo functions.php
del tema actual:
/**
* Register the Smart Tag so it will be available to select in the form builder.
*
* @link https://wpforms.com/developers/how-to-create-a-custom-smart-tag/
*
*/
function wpf_dev_register_smarttag( $tags ) {
// Key is the tag, item is the tag name.
$tags['dia_actual'] = 'Dia actual';
$tags['mes_actual'] = 'Mes actual';
return $tags;
}
add_filter( 'wpforms_smart_tags', 'wpf_dev_register_smarttag' );
/**
* Process the Smart Tag.
*
* @link https://wpforms.com/developers/how-to-create-a-custom-smart-tag/
*
*/
function wpf_dev_process_smarttag( $content, $tag ) {
// Reemplazar el tag con codigo generado en PHP
if ( 'dia_actual' === $tag ) {
$content = str_replace( '{dia_actual}', date("j"), $content );
}
if ( 'mes_actual' === $tag ) {
$content = str_replace( '{mes_actual}', date("F"), $content );
}
return $content;
}
add_filter( 'wpforms_smart_tag_process', 'wpf_dev_process_smarttag', 10, 2 );
Luego solo se necesita el smart tag adecuado para incluirlo en el form (ej: {dia_actual})
Al {dia_actual} del mes de ...