wp_insert_term_duplicate_term_check filter-hookWP 5.1.0

Filters the duplicate term check that takes place during term creation.

Term parent + taxonomy + slug combinations are meant to be unique, and wp_insert_term() performs a last-minute confirmation of this uniqueness before allowing a new term to be created. Plugins with different uniqueness requirements may use this filter to bypass or modify the duplicate-term check.

Usage

add_filter( 'wp_insert_term_duplicate_term_check', 'wp_kama_insert_term_duplicate_check_filter', 10, 5 );

/**
 * Function for `wp_insert_term_duplicate_term_check` filter-hook.
 * 
 * @param object $duplicate_term Duplicate term row from terms table, if found.
 * @param string $term           Term being inserted.
 * @param string $taxonomy       Taxonomy name.
 * @param array  $args           Term arguments passed to the function.
 * @param int    $tt_id          term_taxonomy_id for the newly created term.
 *
 * @return object
 */
function wp_kama_insert_term_duplicate_check_filter( $duplicate_term, $term, $taxonomy, $args, $tt_id ){

	// filter...
	return $duplicate_term;
}
$duplicate_term(object)
Duplicate term row from terms table, if found.
$term(string)
Term being inserted.
$taxonomy(string)
Taxonomy name.
$args(array)
Term arguments passed to the function.
$tt_id(int)
term_taxonomy_id for the newly created term.

Changelog

Since 5.1.0 Introduced.

Where the hook is called

wp_insert_term()
wp_insert_term_duplicate_term_check
wp-includes/taxonomy.php 2554
$duplicate_term = apply_filters( 'wp_insert_term_duplicate_term_check', $duplicate_term, $term, $taxonomy, $args, $tt_id );

Where the hook is used in WordPress

Usage not found.