rest_insert_<taxonomy>

Fires after a single term is created or updated via the REST API.

Description

do_action( 'rest_insert_<taxonomy>', (WP_Term) $term, (WP_REST_Request) $request, (bool) $true ); 

The dynamic portion(s) of the hook name refer to the taxonomy slug.

Parameters (3)

0. $term (WP_Term)
Inserted or updated term object.
1. $request (WP_REST_Request)
Request object.
2. $true (bool) => true
True when creating a term, false when updating.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'rest_insert_{$taxonomy}', $term, $request, $true ); 
The following example is for adding a hook callback.
  1. // define the rest_insert_<taxonomy> callback 
  2. function action_rest_insert_taxonomy( $term, $request, $true ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "rest_insert_{$taxonomy}", 'action_rest_insert_taxonomy', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "rest_insert_{$taxonomy}", 'action_rest_insert_taxonomy', 10, 3 ); 

Defined (2)

The action is defined in the following location(s).

/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php  
  1. do_action( "rest_insert_{$this->taxonomy}", $term, $request, true ); 
  1. do_action( "rest_insert_{$this->taxonomy}", $term, $request, false );