wp_set_comment_status [ WordPress Function ]
wp_set_comment_status ( $comment_id, $comment_status, $wp_error = false )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_get_comment_status, get_comment_statuses, wp_transition_comment_status, wp_list_comments, wp_insert_comment
Sets the status of a comment.
The 'wp_set_comment_status' action is called after the comment is handled. If the comment status is not in the list, then false is returned.
Source
<?php
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb;
$status = '0';
switch ( $comment_status ) {
case 'hold':
case '0':
$status = '0';
break;
case 'approve':
case '1':
$status = '1';
if ( get_option('comments_notify') ) {
$comment = get_comment($comment_id);
wp_notify_postauthor($comment_id, $comment->comment_type);
}
break;
case 'spam':
$status = 'spam';
break;
case 'trash':
$status = 'trash';
break;
default:
return false;
}
$comment_old = clone get_comment($comment_id);
if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
if ( $wp_error )
return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
else
return false;
}
clean_comment_cache($comment_id);
$comment = get_comment($comment_id);
do_action('wp_set_comment_status', $comment_id, $comment_status);
wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
wp_update_comment_count($comment->comment_post_ID);
return true;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp set comment status « WordPress Codex
The 'wp_set_comment_status' action is called after the comment is handled and will only be called, if the comment status is either 'hold', 'approve', or 'spam'.
codex.wordpress.org - wp_set_comment_status - Error : Missing argument 2 - WordPress
[resolved] wp_set_comment_status - Error : Missing argument 2 (3 posts) ... add_action('wp_set_comment_status', 'toto' ); function toto($comment_ID, $status ) ...
wordpress.org - wp_set_comment_status Wordpress hook details -- Adam Brown ...
WordPress version history for wp_set_comment_status. This database has information for all major versions from WP 1.2.1 through 3.3.
adambrown.info - action wp_set_comment_status never gets fired when i change the ...
Jan 15, 2012 ... wp_set_comment_status: Runs when the status of a comment changes. Action function arguments: comment ID, status string indicating the new ...
wordpress.stackexchange.com
Gebruikersdiscussies [ wordpress.org ]
- lelkoun on "How to check if the comment was "unspammed"?"
- Big Bagel on "How to check if the comment was "unspammed"?"
- lelkoun on "How to check if the comment was "unspammed"?"
- lelkoun on "wp_set_comment_status does not work!"
- lelkoun on "wp_set_comment_status does not work!"
- lelkoun on "wp_set_comment_status does not work!"
- lelkoun on "wp_set_comment_status does not work!"
- lelkoun on "How to perform an action after marking a comment as spam"
- SchattenMann on "wp_set_comment_status don't working?"
- SchattenMann on "wp_set_comment_status don't working?"