Hello @joswp ,
Please check this MU plugin:
<?php
add_action( 'forminator_quizzes_submit_before_set_fields', function($entry){
$entry->set_fields(
array(
array(
'name' => '_forminator_user_ip',
'value' => Forminator_Geo::get_user_ip(),
)
)
);
});
add_action( 'forminator_before_submit_quizzes', function( $form_model ) {
$form_id = $form_model->id;
$form_ids = array( 69, 74, 20 ); // IDs of the Quizes for disabling submission
if ( in_array( intval( $form_id ), $form_ids, true ) ) {
$user_ip = Forminator_Geo::get_user_ip();
if ( ! empty( $user_ip ) ) {
$last_entry = Forminator_Form_Entry_Model::get_last_entry_by_ip_and_form( $form_id, $user_ip );
if ( ! empty( $last_entry ) ) {
$entry = Forminator_API::get_entry( $form_id, $last_entry );
$current_time = strtotime( date( 'Y-m-d H:i:s' ) );
$future_time = strtotime( '+1 day', strtotime( $entry->date_created_sql ) );
if ( $current_time < $future_time ) {
wp_send_json_success(
array(
'result' => 'You cannot submit this quiz within 24 hours after submitting once!',
'result_url' => '',
'type' => 'nowrong',
)
);
}
}
}
}
},
15
);
Open that PHP file with any code editor. In line number 16, add your quiz id(s) separated with comma (,) for which you want to disable posting for the desired time after submitting one.
The time you can change in the line 28, by changing the number of days:
$future_time = strtotime( '+1 day', strtotime( $entry->date_created_sql ) );
How to use Must Use (MU) plugins https://www.ads-software.com/support/article/must-use-plugins/
kind regards,
Kasia