WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/pre term description

Description

The pre_term_description action is used to hook into code before a term is updated in the database.

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

Parameters

$description
(string) (required) contents of the description
Default: None
$taxonomy
(string) (required) Taxonomy slug of the related term
Default: None

Examples

functions.php

<?php 
add_action( 'pre_term_description', 'do_something_before_update', 10, 2 ); 

function do_something_before_update( $description, $taxonomy ) {
    switch ( $taxonomy ) {
        case 'category':
            // the term to be saved is a category description
            break;
        case 'post_tag':
            // the term to be saved is a post tag description
            break;
    }
    // the returned description is what's being saved to the database
    return $description;  
}
?>

See Also