Thank you for your inquiry.
You should use the “cdbt_shortcode_custom_forms” filter if you want it.
For example, the way to use is as follows:
function my_shortcode_custom_forms( $elements_options, $shortcode_name, $table ){
$filtered_tables = [ 'your_table_name' ];
$target_shortcodes = [ 'cdbt-entry', 'cdbt-edit' ];
if ( ! is_admin() && in_array( $shortcode_name, $target_shortcodes ) && in_array( $table, $filtered_tables ) ) {
foreach ( $elements_options as $_i => $_option ) {
switch ( $_option['elementName'] ) {
case 'current_date': // please modify to your column name
$elements_options[$_i]['elementType'] = 'hidden';
$elements_options[$_i]['defaultValue'] = date_i18n( 'Y-m-d' );
break;
}
}
}
return $elements_options;
}
add_filter( 'cdbt_shortcode_custom_forms', 'my_shortcode_custom_forms', 10, 3 );
However, there does not work code above when the type of hidden column is “date” type, because that’s a bug.
If you want to perform as same case at the column of “date” type, please use together the filter hooks below.
function my_cdbt_before_upsert_data( $data, $table_name, $field_format ){
$filtered_tables = [ 'your_table_name' ];
$filtered_column = 'current_date'; // please modify to your column name
if ( in_array( $table_name, $filtered_tables ) ) {
if ( array_key_exists( $filtered_column, $data ) ) {
$data[$filtered_column] = date_i18n( 'Y-m-d' );
}
}
return $data;
}
add_filter( 'cdbt_before_insert_data', 'my_cdbt_before_upsert_data', 10, 3 );
add_filter( "cdbt_before_update_data", "my_cdbt_before_upsert_data", 10, 3 );
Please try it.
Thank you,
-
This reply was modified 8 years, 2 months ago by ka2.