Inform user about automatic comment closing time

Posted by | | Uncategorized · Wordpress

To prevent spammers from flooding old articles with useless comments you can set WordPress to close comments after a certain number of days:It might be surprising for some users if the comments are closed automatically so it might be a good idea to inform them about the remaining time. add_action( ‘comment_form_top’, ‘topic_closes_in’ ); function topic_closes_in() { global $post; if ($post->comment_status == ‘open’) { $close_comments_days_old = get_option( ‘close_comments_days_old’ ); $expires = strtotime( “{$post->post_date_gmt} GMT” ) + $close_comments_days_old * DAY_IN_SECONDS; printf( __( ‘(This topic will automatically close in %s. )’, ‘domain’ ), […]

Read More