WP HOOKS
filtrod 4.7.0

rest_pre_insert_comment

Args 2Plik wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.phpDokumentacja WP ↗

Opis — z kodu źródłowego

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.

Parametry

ParametrTypOpis
$prepared_commentarray | \WP_ErrorThe prepared comment data for wp_insert_comment().
$request\WP_REST_RequestRequest used to insert the comment.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_pre_insert_comment', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii