Hi @creativecatapps,
Could you please try this code snippet and then check whether it helps?
<?php
add_filter( 'forminator_cform_form_is_visible', 'wpmudev_formi_form_can_show', 10, 3 );
function wpmudev_formi_form_can_show( $can_show, $id, $form_settings ) {
if ( 2910 != $id ) {
return $can_show;
}
$now = strtotime('now');
$this_day = date( 'j', $now );
$days_this_month = date( 't', $now );
$month = date( 'n', $now );
$form_meta = get_post_meta( $id, 'forminator_form_meta', true );
if ( ! empty( $form_meta ) ) {
$update_meta = false;
if ( ! empty( $form_meta['settings']['expire_submits'] ) ) {
$entries = wpmudev_get_months_entries( $id, $month );
if ( $this_day == 1 && ! $can_show ) {
if ( empty( $entries ) || count( $entries ) < 16 ) {
$expire_submits = $form_meta['settings']['expire_submits'] + 16;
$form_meta['settings']['expire_submits'] = $expire_submits;
$update_meta = true;
}
}
}
if ( $update_meta ) {
update_post_meta( $id, 'forminator_form_meta', $form_meta );
$can_show = true;
}
}
return $can_show;
}
function wpmudev_get_months_entries( $id, $month ) {
global $wpdb;
$entry_table_name = Forminator_Database_Tables::get_table_name( Forminator_Database_Tables::FORM_ENTRY );
$sql = "SELECT <code>entry_id</code> FROM {$entry_table_name} WHERE <code>form_id</code> = %d AND MONTH(<code>date_created</code>) = %d";
$entries = $wpdb->get_results( $wpdb->prepare( $sql, $id, $month ) );
if ( ! empty( $entries ) ) {
return $entries;
}
return false;
}
You’ll have to update the following line from the above code to your forms ID, ie:
if ( 2910 != $id ) {
Suppose your Form ID is 123, then the above will change to:
if ( 123 != $id ) {
Please do note that the code checks if this is the first day of the month and then adds +16 to the previous value.
The above snippet can be added as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Kind Regards,
Nithin