開 Spam Karma 2 以後,把自己留言的通知電郵擋住

因為 SK2 有自己的電郵通知函式,所以跟小弟自行撰寫的小程序有點衝突,開了 SK 2 後往往也會接收到自己留言通知的電郵,對我來說實在非常擾人。明明自己留言了嘛,用不著自己通知自己做過的事,不是嗎?

其實修改的辦法非常簡單。只要在 SK2 的 plugin 稍微修改一下,便可以一勞永逸,不用再接收那堆多餘電郵(話說為甚麼 WP 要這樣設計呢?不解)。請使用 WP 內置插件編輯器打開 SK2 插件,找一下 function wp_notify_postauthor。在大括弧裏面找這句:

if ('' == $user->user_email) return false;

在上面加上:

if ($user->ID == $comment->user_id) return false;
if ($user->user_email == $comment->comment_author_email) return false;

儲存就可以了。

As you may have guessed from the title, this is the instruction on how to filter out your own comment notifications if you are using Spam Karma 2. Since Spam Karma 2 has its own version of e-mail notify, it may cause my plugin SCNF not functioning. To get rid of those annoying messages, we have to modify the SK2 plugin itself.

Edit the SK2 plugin using the internal editor (you could call it by clicking the “Edit” link of SK2 on the plugin page). Then, find the line:

if ('' == $user->user_email) return false;

Add these before the line:

if ($user->ID == $comment->user_id) return false;
if ($user->user_email == $comment->comment_author_email) return false;

I suggest copy the text from the textfield to your favourite editor, for example gEdit or Notepad++, search and modify, and copy the whole back to the textfield overwriting the old content, since your local editor has a nicer interface and a search function. Beware there should be 2 same lines, you should add the lines to both places. When you are done, save it and say goodbye to them!

3 thoughts on “開 Spam Karma 2 以後,把自己留言的通知電郵擋住

Leave a Reply

Your email address will not be published. Required fields are marked *