do_action( "edited_{$taxonomy}", int $term_id, int $tt_id, array $args )

Fires after a term for a specific taxonomy has been updated, and the term cache has been cleaned.


Description

The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.

Possible hook names include:

  • edited_category
  • edited_post_tag

Top ↑

Parameters

$term_id int
Term ID.
$tt_id int
Term taxonomy ID.
$args array
Arguments passed to wp_update_term() .
More Arguments from wp_update_term( ... $args ) Array of arguments for updating a term.
  • alias_of string
    Slug of the term to make this term an alias of.
    Default empty string. Accepts a term slug.
  • description string
    The term description. Default empty string.
  • parent int
    The id of the parent term. Default 0.
  • slug string
    The term slug to use. Default empty string.

Top ↑

More Information

The edit_$taxonomy action is used to hook into code after a custom taxonomy term is updated in the database.

A plugin (or theme) can register an action hook from the example below.


Top ↑

Source

File: wp-includes/taxonomy.php. View all references

do_action( "edited_{$taxonomy}", $term_id, $tt_id, $args );


Top ↑

Changelog

Changelog
Version Description
6.1.0 The $args parameter was added.
2.3.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Akira Tachibana

    Example from Codex

    <?php 
    add_action( 'edited_custom_taxonomy', 'custom_term_slug_edit_success', 10, 2 );
    
    /**
     * Custom redirect on taxonomy term update, keeps users on the term page for additional updates
     *
     * @param $term_id
     * @param $tt_id
     */
    function custom_term_slug_edit_success( $term_id, $tt_id ) {
      
        // Get the taxonomy slug.
        $term = get_term( $term_id );
        $tax_slug = $term->taxonomy;
        
        // Setup the redirect URL.
        $tax_param = '&taxonomy=' . $taxonomy_slug;
        $term_param = '&tag_ID=' . $term_id;
        $notice_param = '&notice=success';
        $redirect_url = admin_url( 'edit-tags.php?action=edit' . $tax_param . $tag_param . $notice_param );
    
        // Redirect with new query strings.
        wp_safe_redirect( $redirect_url );
        exit;
    
    }
    ?>
  2. Skip to note 2 content
    Contributed by Collins Mbaka
    add_action( 'edited_custom_taxonomy', 'custom_term_slug_edit_success', 10, 2 );
    
    /**
     * Custom redirect on taxonomy term update, keeps users on the term page for additional updates
     *
     * @param $term_id
     * @param $tt_id
     */
    function custom_term_slug_edit_success( $term_id, $tt_id ) {
      
        // Get the taxonomy slug.
        $term = get_term( $term_id );
        $tax_slug = $term->taxonomy;
        
        // Setup the redirect URL.
        $tax_param = '&taxonomy=' . $taxonomy_slug;
        $term_param = '&tag_ID=' . $term_id;
        $notice_param = '&notice=success';
        $redirect_url = admin_url( 'edit-tags.php?action=edit' . $tax_param . $tag_param . $notice_param );
    
        // Redirect with new query strings.
        wp_safe_redirect( $redirect_url );
        exit;
    
    }

You must log in before being able to contribute a note or feedback.