created_term

What is WordPress Hook: created_term

The created_term hook is a specific WordPress hook that is triggered after a new term has been created in a taxonomy.

Understanding the Hook: created_term

The created_term hook is located within the wp_insert_term() function, which is responsible for inserting a new term into a taxonomy. This hook allows developers to perform additional actions after a new term has been successfully created.

Hook Parameters (if applicable): created_term

The created_term hook accepts three parameters: $term_id, $tt_id, and $taxonomy. The $term_id parameter is the ID of the newly created term, $tt_id is the term taxonomy ID, and $taxonomy is the taxonomy of the term.

Hook Doesn’t Work: created_term

If the created_term hook doesn’t work as expected, it could be due to incorrect usage or a conflict with other hooks or functions. It’s important to double-check the syntax and placement of the hook to ensure it is being triggered at the right time.

Best Practices & Usage Notes (if applicable): created_term

When using the created_term hook, it’s important to keep in mind that any actions performed within the hook will affect all instances of term creation within the specified taxonomy. It’s best to use this hook for lightweight actions to avoid slowing down the term creation process.

Usage Example: created_term

“`php
function custom_function_after_term_created( $term_id, $tt_id, $taxonomy ) {
// Perform custom actions after a term is created
}
add_action( ‘created_term’, ‘custom_function_after_term_created’, 10, 3 );
“`

Article Tags

Buy Now Bundle and save over 60%

Buy now