edit_comment

Update a comment with values provided in $_POST.

Description

edit_comment(); 

Usage

  1. if ( !function_exists( 'edit_comment' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/comment.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = edit_comment(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/comment.php  
  1. function edit_comment() { 
  2. if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) 
  3. wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); 
  4.  
  5. if ( isset( $_POST['newcomment_author'] ) ) 
  6. $_POST['comment_author'] = $_POST['newcomment_author']; 
  7. if ( isset( $_POST['newcomment_author_email'] ) ) 
  8. $_POST['comment_author_email'] = $_POST['newcomment_author_email']; 
  9. if ( isset( $_POST['newcomment_author_url'] ) ) 
  10. $_POST['comment_author_url'] = $_POST['newcomment_author_url']; 
  11. if ( isset( $_POST['comment_status'] ) ) 
  12. $_POST['comment_approved'] = $_POST['comment_status']; 
  13. if ( isset( $_POST['content'] ) ) 
  14. $_POST['comment_content'] = $_POST['content']; 
  15. if ( isset( $_POST['comment_ID'] ) ) 
  16. $_POST['comment_ID'] = (int) $_POST['comment_ID']; 
  17.  
  18. foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { 
  19. if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { 
  20. $_POST['edit_date'] = '1'; 
  21. break; 
  22.  
  23. if ( !empty ( $_POST['edit_date'] ) ) { 
  24. $aa = $_POST['aa']; 
  25. $mm = $_POST['mm']; 
  26. $jj = $_POST['jj']; 
  27. $hh = $_POST['hh']; 
  28. $mn = $_POST['mn']; 
  29. $ss = $_POST['ss']; 
  30. $jj = ($jj > 31 ) ? 31 : $jj; 
  31. $hh = ($hh > 23 ) ? $hh -24 : $hh; 
  32. $mn = ($mn > 59 ) ? $mn -60 : $mn; 
  33. $ss = ($ss > 59 ) ? $ss -60 : $ss; 
  34. $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 
  35.  
  36. wp_update_comment( $_POST );