wp_set_comment_status

ACTION wp-includes\comment.php (ligne 2518) github
Sets the status of a comment. The {@see '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.
traduction française
Définit le statut d'un commentaire. L'action {@see 'wp_set_comment_status'} est appelée après le traitement du commentaire. Si le statut du commentaire n'est pas dans la liste, false est renvoyé.

Paramètres

Entrée :
$comment_id, $comment_status, $wp_error = false
Sortie :
@param int|WP_Comment $comment_id     Comment ID or WP_Comment object.
@param string         $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.
@param bool           $wp_error       Whether to return a WP_Error object if there is a failure. Default false.
@return bool|WP_Error True on success, false or WP_Error on failure.

Utilisation

Exécuter une action lors du changement de statut de commentaire

Action déclenchée quand le statut change.

content
add_action('wp_set_comment_status', 'log_comment_moderation', 10, 2);
function log_comment_moderation($comment_id, $status) {
    error_log('Comment ' . $comment_id . ' status: ' . $status);
}

Actualités

Chargement des actualités...