rest_insert_{$this->post_type}

ACTION wp-includes\rest-api\endpoints\class-wp-rest-posts-controller.php (ligne 805) github
Fires after a single post is created or updated via the REST API. The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. Possible hook names include:  - `rest_insert_post`  - `rest_insert_page`  - `rest_insert_attachment`

Paramètres

Entrée :
$post, $request, true
Sortie :
@param WP_Post         $post     Inserted or updated post object.
@param WP_REST_Request $request  Request object.
@param bool            $creating True when creating a post, false when updating.

Utilisation

// Ajouter une fonction au hook action 'rest_insert_{$this->post_type}'
add_action('rest_insert_{$this->post_type}', 'ma_fonction_personnalisee', 10, 1);

function ma_fonction_personnalisee($post, $request, true) {
    // Votre code ici
    error_log('Hook rest_insert_{$this->post_type} déclenché');
}

Actualités

Chargement des actualités...