During my time as a blogger, I’ve somewhat-frequently run into an occurrence when I’d like to add a private note to comment that someone publishes on my site. Instead of simply responding to a comment and making that response publicly visible, I wanted something that could only be seen by me and, optionally, the commenter. Whether I want to add something like a simple “note-to-self” or “note-to-commenter,” I thought it would be great to have a system that would allow me to easily add these kinds of “notes” to a comment.
Today, I published to the WordPress plugin repository the WP Private Comment Notes plugin. It is a simple plugin that lets comment moderators add and remove notes for any comment from the WordPress admin. Here’s an example screenshot:
When you navigate to any comment’s admin page, you will have the ability to add a new note to the comment. With each note, you will also have the option to send the content of the note to the person who left the comment. If needed, you can also delete your notes. That’s all there is to it!
For Developers
If needed, there is also a number of hooks available:
wp_private_comment_notes_display_order
– By default, comment notes are displayed in descending order, according to time added. Return either “DESC” (default), or “ASC” for ascending.wp_private_comment_notes_should_send_email
– Whether an email should be sent to the commenter. Default: true. Return true or false.wp_private_comment_notes_email_subject
– Subject of the email sent to commenter. Return a subject (string). Accepts a$note
array and$comment
object (see here for the WordPress comment object).wp_private_comment_notes_email_message
– Message of the email. Return a message (string). Accepts a$note
array and$comment
object.wp_private_comment_notes_email_headers
– Headers of the email (i.e. content type, from info, etc.). Return an array. Accepts a$note
array,$comment
object, and$from_user
object (WP_User), which is the user who added the note.wp_private_comment_notes_capability
– Capability required to add/remove comment notes. Return a WordPress capability. Accepts a$user_id
Further, a note array will have the following structure:
array( 'date' => $date, // timestamp for when the note was added 'user_id' => $user_id, // ID of user who added note 'note' => $note, // note content 'email_commenter' => (int) $send // whether email was sent to commenter )
Feel free to get in touch with any questions. Enjoy!
Leave a Reply