WordPress.org

Ready to get started?Download WordPress

Forums

Change how often users can comment? (1 post)

  1. jgadsby
    Member
    Posted 1 year ago #

    I've found the relevant code - how do I change how often users can comment?

    function check_comment_flood_db( $ip, $email, $date ) {
    
    	global $wpdb;
    
    	if ( current_user_can( 'manage_options' ) )
    
    		return; // don't throttle admins
    
    	$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
    
    	if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT <code>comment_date_gmt</code> FROM <code>$wpdb->comments</code> WHERE <code>comment_date_gmt</code> >= %s AND ( <code>comment_author_IP</code> = %s OR <code>comment_author_email</code> = %s ) ORDER BY <code>comment_date_gmt</code> DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) {
    
    		$time_lastcomment = mysql2date('U', $lasttime, false);
    
    		$time_newcomment  = mysql2date('U', $date, false);
    
    		$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
    
    		if ( $flood_die ) {
    
    			do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
    
    			if ( defined('DOING_AJAX') )
    
    				die( __('You are completing tasks too quickly. Try completing the task in real life first, and try again later.') );
    
    			wp_die( __('You are completing tasks too quickly. Try completing the task in real life first, and try again later.'), '', array('response' => 403) );
    
    		}
    
    	}

    Thanks for any help!

Topic Closed

This topic has been closed to new replies.

About this Topic