rest_pre_insert_comment

FILTER wp-includes\rest-api\endpoints\class-wp-rest-comments-controller.php (ligne 780) github
Filters a comment before it is inserted via the REST API. Allows modification of the comment right before it is inserted via wp_insert_comment(). Returning a WP_Error value from the filter will short-circuit insertion and allow skipping further processing.

Paramètres

Entrée :
$prepared_comment, $request
Sortie :
@param array|WP_Error  $prepared_comment The prepared comment data for wp_insert_comment().
@param WP_REST_Request $request          Request used to insert the comment.

Utilisation

// Modifier la valeur avec le filtre 'rest_pre_insert_comment'
add_filter('rest_pre_insert_comment', 'ma_fonction_filtre', 10, 1);

function ma_fonction_filtre($prepared_comment) {
    // Modifier la valeur
    return $prepared_comment;
}

Actualités

Chargement des actualités...