• Okay, the topic title is a little off.

    Basically, what I want to do is this.

    I have my blog setup to email whenever a comment is made to one of my posts. It works great, and I get the emails no problem.
    However, if I make a comment to my blog, I get an email telling me that I made a comment.

    Is there a way to have it so when I make a comment myself, it won’t email me. But I want to receive the emails for comments from other people.

    I tried to search here, but didnt’ find what I was looking for.

    thanks in advance.

Viewing 15 replies - 16 through 30 (of 48 total)
  • Thread Starter vryce

    (@vryce)

    When I make a post, I am logged in as the blog admin.
    If I comment on a post I made, I’m logged in as well and it grabs the email address that I defined in my blog settings.

    For a test, I logged out and tried to reply to a post I made, using the same email address as what it would ahve for the post author(the email address defined in the blog settings)

    An email still arrived after I made the post.

    Changed my email in profile. Still sends me an email from the test comment.

    <?php
    /*
    Plugin Name: not-to-me
    Plugin URI: https://www.skippy.net/
    Description: suppress emails to blog admin when they comemnt
    Version: 1.0
    Author: Scott Merrill
    Author URI: https://www.skippy.net/
    */

    add_action('comment_post', 'not_to_me');

    function not_to_me($ID = 0) {
    global $cache_settings;

    $comment = get_commentdata($ID, 1, 1);
    if (get_settings('admin_email') == $comment['comment_author_email']) {
    $foo = get_settings('comments_notify'); // make sure it's cached
    $cache_settings->comments_notify = 0;
    }
    return $ID;
    }
    ?>

    Tested. Works for me. Currently only suppresses emails when the admin comments. I’ll leave it as an exercise to the reader to suppress emails when the psot author comments.

    Okay – giving it another shot with the above! You’re a great guy, y’know? Thanks!

    Thread Starter vryce

    (@vryce)

    Hmm.. can’t get it to work for me.

    I’m logged in as the admin, and am the post author.

    I’ll do some playing around and see what I can figure out. It probably has to do that I’m posting as admin and commenting as admin as well. Though, by the logic you used, I shouldn’t get an email.

    For testing purposes, I added these lines into the file, just to see what it was getting.

    echo get_settings(‘admin_email’);
    echo $comment[‘comment_author_email’];

    Both of the lines returned were the same and are what is in my options as the admin email.

    Tried it, still sending me mail (even after I changed it back to the admin email) – and I’m of course still logged in under the admin name for the blog I’m testing on. So I logged out, and then back in again as the appropriate “me” admin for the site just to be positive – and posted another test comment. Still sent it to me.

    It’s really nice of you to mess with this.

    To be clear: when I say “admin email address”, I mean the email address you define in Options -> General, and not the email address of the user named “admin” in the Users & Profiles tab.

    If that email address is the one you are supplying when commenting, then something else is happening, which I’ll try to diagnose.

    Yes, that’s what I assumed you were meaning, and yes, that’s the email address I post from. After I updated with your other plugin info, I also tried posting in my “admin” persona as normal but from the other email as well, both give me a mail notification re the comment posting.

    However, now that I reread a bit: I’m not actively supplying an email addy when commenting, it doesn’t ask for one if I’m logged in…. It’s assumedly just accessing the info from the logged in user info?

    If you’re not being prompted to fill in an email address when you comment, then the comment form is most likely reading a cookie from a previous comment. You might try deleting all your cookies, and posting a new comment to ensure the proper email is being used.

    Here’s a modified version of this plugin:
    <?php
    /*
    Plugin Name: not-to-me
    Plugin URI: https://www.skippy.net/
    Description: suppress emails to post authors and blog admin when they comemnt
    Version: 1.0
    Author: Scott Merrill
    Author URI: https://www.skippy.net/
    */

    add_action('comment_post', 'not_to_me');

    function not_to_me($ID = 0) {
    global $cache_settings;

    $blog_email = get_settings('admin_email');
    $admin = get_userdata(1);
    $admin_email = $admin->user_email;
    $post_author = get_the_author_email();

    $comment = get_commentdata($ID, 1, 1);
    $comment_author = $comment['comment_author_email'];

    if ( ($comment_author == $blog_email) || ($comment_author == $admin_email) || ($comment_author == $post_author) ) {
    $foo = get_settings('comments_notify'); // make sure it's cached
    $cache_settings->comments_notify = 0;
    }
    return $ID;
    }
    ?>

    If you want to test whether the if() condition is true (which means that the comment email is coming from either the blog admin email, the admin user’s email, or the post author’s email), insert the following line just after the if() :
    die('Yes!');
    That will halt execution of the plugin (and WordPress) and dislpay “Yes!”. If you see “Yes”, and then remove that line and _still_ get email notifications, then some other thing is happening… Perhaps another plugin? Maybe “subscribe to comments” ?

    Okay. I put the die('Yes!'); code in and tested. I saw Yes!, removed the line, and still get mail notifications. I input a new post from both addys, and commented in each logged in with the correct addy. Still got emails. Then I deleted all cookies for the site. Still got emails.

    I don’t have anything like subscribe to comments installed. Could be one of my other dozen plugins I guess. I’m going to put this on a site that has only a couple of the spam things. I’ll post back.

    I installed this on a blog with only 4 plugins: WPSpam Assassin; Spam Karma; Postman; and WeatherIcon2. Still got emails. Disabled all the plugins except not-to-me. Still got emails.

    Could this be so hard-coded in the core php that there’s no way around it by using a plugin?

    I tested the plugin on my test install, using a stock 1.5 install. It works for me.

    Right after $cache_settings->comments_notify = 0;, insert the following:
    print_r($cache_settings); die;

    Make a comment. Look at the output. Find the comments_notify setting, to check its value. It _should_ be zero. If it is zero, then I’ve no idea why this isn’t working for you.

    I’m not sure where I should be looking at the output? Sorry to be such a pain!

    In the output, press CTRL+F to searh for comments_notify. It should look like:
    [comments_notify] => 0

Viewing 15 replies - 16 through 30 (of 48 total)
  • The topic ‘How to stop getting email notificaiton of comment if you made the comment?’ is closed to new replies.