Limit postings per day
-
Hello
I found this code below can it be modified to work with accesspress anonymous post. how can I restrict/limit logged in users to publish only blog post per day. Each logged in user should not be able to post more than one blog post entry per day using the Frontend Post Plugin.
/**
* Limit User to One Submission Per Time Period
* https://gravitywiz.com/2012/04/25/limit-user-to-one-submission-per-time-period/
*/// update the “5” to your form ID
add_action(‘gform_pre_render_5’, ‘gform_limit_submissions’);
function gform_limit_submissions($form){
global $wpdb;$limit_message = ‘You may only submit this form once every 24 hours.’;
$limit_time = 86400; // must be specified in seconds; 86400 seconds is equal to 24 hours/* You do not need to edit below this line */
$current_user = wp_get_current_user();
$last_submission = $wpdb->get_var($wpdb->prepare(“SELECT date_created FROM {$wpdb->prefix}rg_lead WHERE created_by = %d and form_id = %d ORDER BY date_created DESC”, $current_user->ID, $form[‘id’]));if(empty($last_submission))
return $form;$time_out = strtotime($last_submission) + $limit_time;
$current_time = time();if($current_time > $time_out)
return $form;$is_submit = rgpost(“is_submit_{$form[‘id’]}”);
if(!$is_submit) {
add_filter(‘gform_get_form_filter’, create_function(”, “return ‘<div class=\”limit-message\”>$limit_message</div>’;”) );
}return $form;
}I got this code from https://gravitywiz.com/limit-user-to-one-submission-per-time-period/
- The topic ‘Limit postings per day’ is closed to new replies.