2

just want to change a little bit author email notify message(wp_notify_postauthor - pluggable.php),and I'm applying filters on comment_notification_text

function myfunction(){
  return "<div class='left_side'>"..$comment..$post.."</div>"
}

add_filter('comment_notification_text', 'myfunction');

How to access data $comment,$post,... in myfunction ?

3

$comment_id can be passed as second parameter to your function.

Modify you add_filter:

add_filter('comment_notification_text', 'myfunction', 10, 2);

Then get $comment and $post from $comment_id:

function myfunction( $notify_message, $comment_id ) {
    $comment = get_comment( $comment_id );
    $post    = get_post($comment->comment_post_ID);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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