Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We're using the disqus plugin on our wordpress site, so anyone commenting should have a login through disqus. Yet, I'm still seeing spammers trying to post through the regular comments API. They're not getting through to the post, but they're clogging my inbox as admin.

How do I disable this API - I only want to accept comments that come from a logged in Disqus user?

share|improve this question

migrated from webmasters.stackexchange.com Mar 4 '13 at 1:04

This question came from our site for pro webmasters.

2 Answers 2

up vote 1 down vote accepted

There is much easier way to close standard WordPress comments. Just add

add_filter( 'comments_open', '__return_false' );

to your functions.php file and comments will be closed.

share|improve this answer
    
But will this close all comments? I want to allow comments through Disqus - just not the ones coming in through the API. –  ChristopherJ Mar 8 '13 at 10:54
    
@ChristopherJ it will close all WordPress comments. Disqus comments will work. –  Eugene Manuilov Mar 8 '13 at 10:57
    
It's reduced our load. We're still getting some sneaking in through trackbacks, but I guess that's a different API point. –  ChristopherJ Jul 29 '13 at 1:54

You can try to stop it in the pre_comment_on_post hook

add_action('pre_comment_on_post', 'no_wp_comments');
function no_wp_comments() {
        wp_die('No comments');
}

I use this when I use Facebook comments instead of Wordpress comments.

Here is a similar example with an anonymous function:

add_action('pre_comment_on_post', create_function( '','wp_die("No comments");'));

but I prefer the first example, it's easier to modify.

This hook is in the file wp-comments-post.php as:

do_action('pre_comment_on_post', $comment_post_ID);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.