Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Change Admin Comment Notification Subject Line, Code Included.. WordPress

  • SOLVED

Hi,

Currently the standard admin comment notification subject line looks like this:

[Site Title] Please moderate: "Sample Page"

I would like to see this changed to:

[Comment ID] - Site Title - My Text

In this order:

1: Comment ID inside [ ]
2: - Site Title
3: - Custom Verbiage

Regarding #3, it's not required to include the Page Name, this needs to be replaced with static verbiage.


There is a Function Reference mentioned in the WordPress Codex:

http://codex.wordpress.org/Function_Reference/wp_notify_moderator

There is also a core WordPress file pluggable.php file that holds this function:

wp_notify_moderator

This controls the output that needs to be modified.

Problem for me is to create something I can paste into functions.php that will result in the above explained output.


Thanks!

Answers (1)

2011-02-25

Utkarsh Kukreti answers:

add_filter('comment_moderation_subject', 'custom_moderation_subject');
function custom_moderation_subject($subject, $comment_id) {
$site_title = get_bloginfo();
return "[$comment_id] - $site_title - Custom Text";
}


Edwin comments:

Hi Utkarsh,

It looks like you almost got it, upon submitting a comment I received the following errors on a white screen:

Warning: Missing argument 2 for custom_moderation_subject() in /home/mydirectory/public_html/mydomain.com/wp-content/themes/twentyten/functions.php on line 288

Warning: Cannot modify header information - headers already sent by (output started at /home/mydirectory/public_html/mydomain.com/wp-content/themes/twentyten/functions.php:288) in /home/mydirectory/public_html/mydomain.com/wp-comments-post.php on line 95

Warning: Cannot modify header information - headers already sent by (output started at /home/mydirectory/public_html/mydomain.com/wp-content/themes/twentyten/functions.php:288) in /home/mydirectory/public_html/mydomain.com/wp-comments-post.php on line 96

Warning: Cannot modify header information - headers already sent by (output started at /home/mydirectory/public_html/mydomain.com/wp-content/themes/twentyten/functions.php:288) in /home/mydirectory/public_html/mydomain.com/wp-comments-post.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /home/mydirectory/public_html/mydomain.com/wp-content/themes/twentyten/functions.php:288) in /home/mydirectory/public_html/mydomain.com/wp-includes/pluggable.php on line 897


Utkarsh Kukreti comments:

Ah, please try

add_filter('comment_moderation_subject', 'custom_moderation_subject', 10, 2);


Edwin comments:

That's it! - Thank you so much!