Action hook 'pre_delete_term'

in WP Core File wp-includes/taxonomy.php at line 2082

View Source

pre_delete_term

Action Hook
Description
Fires when deleting a term, before any modifications are made to posts or terms.

Hook Information

File Location wp-includes/taxonomy.php View on GitHub
Hook Type Action
Line Number 2082

Hook Parameters

Type Name Description
int $term Term ID.
string $taxonomy Taxonomy name.

Usage Examples

Basic Usage
<?php
// Hook into pre_delete_term
add_action('pre_delete_term', 'my_custom_function', 10, 2);

function my_custom_function($term, $taxonomy) {
    // Your custom code here
}

Source Code Context

wp-includes/taxonomy.php:2082 - How this hook is used in WordPress core
<?php
2077  	 * @since 4.1.0
2078  	 *
2079  	 * @param int    $term     Term ID.
2080  	 * @param string $taxonomy Taxonomy name.
2081  	 */
2082  	do_action( 'pre_delete_term', $term, $taxonomy );
2083  
2084  	// Update children to point to new parent.
2085  	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
2086  		$term_obj = get_term( $term, $taxonomy );
2087  		if ( is_wp_error( $term_obj ) ) {

PHP Documentation

<?php
/**
	 * Fires when deleting a term, before any modifications are made to posts or terms.
	 *
	 * @since 4.1.0
	 *
	 * @param int    $term     Term ID.
	 * @param string $taxonomy Taxonomy name.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/taxonomy.php
Related Hooks

Related hooks will be displayed here in future updates.