Last active
December 28, 2015 20:39
-
-
Save TomiToivio/7558625 to your computer and use it in GitHub Desktop.
Do something when admin posts a comment reply in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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