Skip to content

Instantly share code, notes, and snippets.

@TomiToivio
Last active December 28, 2015 20:39
Show Gist options
  • Save TomiToivio/7558625 to your computer and use it in GitHub Desktop.
Save TomiToivio/7558625 to your computer and use it in GitHub Desktop.
Do something when admin posts a comment reply in WordPress.
/* Call the function when comment is posted */
add_action('comment_post', 'my_admin_reply');
function my_admin_reply($id) {
/* Only do it when posting from admin */
if (is_admin()) {
$mycomment = get_comment($id);
$mycommentid = $mycomment->comment_ID;
$mycommentparent = $mycomment->comment_parent;
$mycommentcontent = $mycomment->comment_content;
/* Only do it when the comment has a parent */
if (!empty($mycommentparent)) {
/* Doing something with the comment contents */
$mycommentarr = array();
$mycommentarr['comment_ID'] = $mycommentid;
$mycommentarr['comment_content'] = "Doing something!";
wp_update_comment($mycommentarr);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment