Over the past couple years I’ve worked on a number of WordPress Multi-Sites that wanted to have their comments and pings disabled. In other words, they weren’t accepting comments and didn’t want them to be displayed. Normally this is easy to accomplish, simply turn off comments in the back end.
However, SPAMMERS knowing exactly how WordPress works and how to inject comment SPAM into WordPress. Though, if you do not have comments automatically approved, they definitely should not appear… if a comment does get injected, the WordPress administrator (and author) should receive a notification of a pending comment. So, there is a simple way in WordPress Multi-Site to just set all comment and ping submissions to false. Just stick this little bit of code into a php file in the mu-plugins directory:
1 2 |
add_filter( 'pings_open', '__return_false', 10, 2 ); add_filter( 'comments_open', '__return_false', 10, 2 ); |
One of the Multi-Site installations that I have this enabled in wanted to allow comments on two of their sites. If this is something you need, just setup a mu-plugin php file that looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function comments_and_pings_closed( $open, $post_id ) { global $blog_id; $comment_sites = array( 10, 15 ); // Site IDs of site that you don't want automatically disabled if ( in_array( $blog_id, $comment_sites ) ) { return $open; } return false; } add_filter( 'pings_open', 'comments_and_pings_closed', 10, 2 ); add_filter( 'comments_open', 'comments_and_pings_closed', 10, 2 ); |
AWESOME! Worked as expected.. very nice. My users thank you :D