Trying to add a function to wp-comments-post.php to take place after submit
-
I am trying to excecute a function after a comment is submitted. I keep getting an error regarding the header has already been sent to the browser, etc.
if ( empty($status->comment_status) ) {
do_action(‘comment_id_not_found’, $comment_post_ID);
exit;
} elseif ( !comments_open($comment_post_ID) ) {
do_action(‘comment_closed’, $comment_post_ID);
wp_die( __(‘Sorry, comments are closed for this item.’) );
} elseif ( in_array($status->post_status, array(‘draft’, ‘pending’) ) ) {
do_action(‘comment_on_draft’, $comment_post_ID);
exit;
} else {
do_action(‘pre_comment_on_post’, $comment_post_ID);
global $current_user;
get_currentuserinfo();
$newid = $current_user->avatarid;
$newkey = $current_user->avatarkey;//function executed here
}The error I get is
Warning: Cannot modify header information – headers already sent by (output started at /home/domain/public_html/blog/wp-comments-post.php:120) in /home/domain/public_html/blog/wp-includes/pluggable.php on line 865
Which line in the wp-comments-post.php file can a function be placed? Thanks for your help anyone!
- The topic ‘Trying to add a function to wp-comments-post.php to take place after submit’ is closed to new replies.