WordPress.org

Ready to get started?Download WordPress

Forums

How to stop getting email notificaiton of comment if you made the comment? (49 posts)

  1. Vryce
    Member
    Posted 8 years ago #

    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.

  2. skippy
    Member
    Posted 8 years ago #

    There's no way to suppress the notification of emails you send, by default. This could be facilitated by means of a plugin. If you're interested in such a thing, let me know and I'll see what I can do!

  3. Vryce
    Member
    Posted 8 years ago #

    Thats what I was thinking.
    A plugin would be great. Heck, If I knew more about php and the way wordpress works, I'd do one myself.

    It isn't a big hassle, just something of an annoyance. Hehe. I know that I made a post, I don't need an email on it..

    If you come up with something, I'd definetly be interested and be a guiniea pig to test it out.

    Thanks again for the reply.

  4. vkaryl
    Member
    Posted 8 years ago #

    Add a second tester if you need one.... I rather don't appreciate reminders of my own posts either.

  5. skippy
    Member
    Posted 8 years ago #

    It could be as simple as this (untested):
    <?php
    add_action('comment_post', 'not_to_self', 1);

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

    $comment = get_commentdata($ID);
    if (get_settings('admin_email') == $comment['comment_author_email']) {
    $cache_settings('comments_notify') = 0;
    }
    return $ID;
    }
    ?>

  6. vkaryl
    Member
    Posted 8 years ago #

    Testing - I'll post back.

    [*laughs at self*] Can't test it if I don't know where to put it, can I?

  7. skippy
    Member
    Posted 8 years ago #

    Sorry: save that as a file named "not-to-self.php" in /wp-content/plugins/

    Then activate the plugin.

  8. vkaryl
    Member
    Posted 8 years ago #

    Heh - I almost did that, then thought it couldn't be THAT easy! I'll try it now....

  9. vkaryl
    Member
    Posted 8 years ago #

    Hmm. It doesn't show in the Plugins list, even after clearing cache and hard refreshing.

    Ah. I think it has to have some header info, plugin name etc. Let me tweak it a bit....

  10. Vryce
    Member
    Posted 8 years ago #

    I had to edit it and give it some plugin info like other plugins. I got it to show up and activated it, but it doesn't like this line

    $cache_settings('comments_notify') = 0;

    It responded with an error

    Parse error: parse error, unexpected '='

  11. vkaryl
    Member
    Posted 8 years ago #

    Gave it a plugin name, properly commented the section. Get this error after activation:

    Parse error: parse error, unexpected '=' in /home/karyl/public_html/pov/wp-content/plugins/not-to-self.php on line 13

  12. skippy
    Member
    Posted 8 years ago #

    Ack. Yes, $cache_settings isn't a function, so the parentheses are wrong. Replace that line with this, please:
    $foo= get_settings('comments_notify'); // to make sure it gets cached
    $cache_settings->comments_notify = 0; // change the cached setting to disable notification for this comment

  13. Vryce
    Member
    Posted 8 years ago #

    Got the changes in.. No errros.. but email from me comes through..

    Thanks again for helping out. It really is appreceiated. Hopefully we can figure out the method to get it working through this testing.

  14. vkaryl
    Member
    Posted 8 years ago #

    Yup. Still got a mail from a test comment. Now, I wonder if this has anything to do with the fact that my profile email and the admin email are the same?

  15. skippy
    Member
    Posted 8 years ago #

    Are you posting as the blog administrator, or the post author? Is the email you use when posting the comment the same as the email defined for the blog administrator?

  16. vkaryl
    Member
    Posted 8 years ago #

    Whoever I am when I post, I'm always logged in through the admin name/password (I phrase it that way because it depends which blog I'm in "who" I am - sorry if that makes no sense, I use my various blogs for writing etc. as well as for just "ditzoid" posts) - I tried using a level 9 persona, but then had to login/logout and mutz around when I needed to go from posting to tweaking something. It's just not worth the aggravation....

    Yes, the email I use when posting matches the blog admin email. I'll change "my" email and see what happens.

  17. Vryce
    Member
    Posted 8 years ago #

    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.

  18. vkaryl
    Member
    Posted 8 years ago #

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

  19. skippy
    Member
    Posted 8 years ago #

    <?php
    /*
    Plugin Name: not-to-me
    Plugin URI: http://www.skippy.net/
    Description: suppress emails to blog admin when they comemnt
    Version: 1.0
    Author: Scott Merrill
    Author URI: http://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.

  20. vkaryl
    Member
    Posted 8 years ago #

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

  21. Vryce
    Member
    Posted 8 years ago #

    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.

  22. vkaryl
    Member
    Posted 8 years ago #

    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.

  23. skippy
    Member
    Posted 8 years ago #

    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.

  24. vkaryl
    Member
    Posted 8 years ago #

    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.

  25. vkaryl
    Member
    Posted 8 years ago #

    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?

  26. skippy
    Member
    Posted 8 years ago #

    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: http://www.skippy.net/
    Description: suppress emails to post authors and blog admin when they comemnt
    Version: 1.0
    Author: Scott Merrill
    Author URI: http://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" ?

  27. vkaryl
    Member
    Posted 8 years ago #

    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.

  28. vkaryl
    Member
    Posted 8 years ago #

    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?

  29. skippy
    Member
    Posted 8 years ago #

    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.

  30. vkaryl
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic