comment_email hook doesn’t seem to work for comment editor field

I am building a plugin that allows users to PPK encrypt their users’ IP/email data. Thus, IP/email data is set to dummy values in the comments table and encrypted values are stored in corresponding meta fields. I’m successfully using the comment_email hook to lookup email addresses in the admin comments browser from my encrypted meta values.

When editing a comment in the admin interface, in the Author box the email field is preceded by the label “E-mail (send e-mail)”, where the text in brackets is hyperlinked to the email address. My hook appears to operate correctly there, retrieving the encrypted email address from comment metadata and decrypting it before returning it.

However in the edit field itself, the real (dummy) contents of wp_comments.comment_author_email is revealed. Is there a hook I can use to modify this before the screen opens? I thought perhaps preprocess_comment would do it, but it doesn’t seem to be called.

(I can solve this by adding an AJAX op to this screen and modifying the edit box contents after the screen is rendered. However, that’s a bit hacky, and may be impossible if I try to apply it to the Quick Edit AJAX feature).

1 Answer
1

You have to filter 'get_comment'. The filter is part of the function with the same name. It is called in wp-admin/comment.php?action=editcomment and the comment is passed to the edit form where you see the email.

The parameter is a comment object, you can change the email value here.

Leave a Comment