Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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).

share|improve this question
    
You want to display the decrypted email address in the text field? –  Rutwick Gangurde Jan 1 '13 at 16:45
    
@RutwickGangurde - yes indeed. My plan would then be to re-encrypt it, save that to meta data, and overwrite the value in the comment table with a dummy value again. –  halfer Jan 1 '13 at 16:47
1  
Glad you found a solution below! :) –  Rutwick Gangurde Jan 2 '13 at 5:55

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Aha, too easy! I will give that a try, thanks. Oddly, I can't find that in the filter reference - should that be in there? –  halfer Jan 1 '13 at 16:50
    
@halfer Always read the core source code, do not rely on third party documentation. Hooks are moving targets, and very few people keep the codex up to date. I found that by looking at wp-admin/comment.php and wp-includes/comment.php. –  toscho Jan 1 '13 at 16:52
    
Heh, Wordpress is a third party? :-p. Fair point though, I will bear that in mind. –  halfer Jan 1 '13 at 16:53
    
That's fixed it - thank you. –  halfer Jan 1 '13 at 18:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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