create_term
as you can see in inline docs in code
Fires immediately after a new term is created, before the term cache
is cleaned
So you can’t prevent an event after that event already happen.
To prevent a term is inserted you can use 'pre_insert_term'
filter hook and return a WP_Error
a 0
or an empty string.
Example:
add_filter( 'pre_insert_term', 'prevent_add_term', 20, 2 );
function prevent_add_term( $term, $taxonomy ) {
if ( $term === 'i-am-a-bad-term' ) {
$term = new WP_Error( 'invalid_term', 'Term you tried to add sucks' );
}
return $term;
}
Related Posts:
- How to know what functions are hooked to an action/filter?
- Is there a hook that runs after a user logs in?
- Difference between do_action and add_action
- Why do some hooks not work inside class context?
- Difference between after_setup_theme and init action hooks?
- Trigger custom action when setting button pressed
- Please explain how these hooks work
- Hook after image is uploaded and image sizes generated
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- How to remove action hook done in a plugin from functions.php in my theme?
- trigger save_post event programmatically
- Implementing advanced add_* function wrappers
- My add_action (wp_footer, ‘method’) is not calling?
- What is the earliest possible hook for safely using `is_front_page`?
- How to check if which hook triggered the call to a function?
- Send data to 3rd party api with wp_remote_post on wp_login
- is it possible to get the hook name in add_action?
- Run javascript code after wp_login hook?
- Difference between hooks Plugin_loaded and admin_int?
- Redirect logged in users if they are on a specific page
- admin_post hook not called
- Check if action hook exists before adding actions to it
- Send an email when custom post type category is changed
- Hooks are not executing
- How to debug removal of rewrite rule flushing?
- after login that will redirect user role into a page
- add_action on inherit post status
- Detect type of post status transition
- Create hooks based on an array of hook names?
- Hook before inserting user into database [duplicate]
- How to pass arguments to add_action() [duplicate]
- action lifecycle
- How to use the post_updated hook before and after arguments
- Is there a recover_post hook to go with trash_post hook?
- Redirect users on specific post category or category page
- WP Admin Bar frontend issue with dashicon deregister
- How can i trigger an action manually?
- How to get post ID in post_updated action hook?
- wp_redirect() not working on form submission with init hook
- add_action for lost_password or modify wp-login.php?action=lostpassword
- Run add_action hook if condition
- Add my own function to existing WooCommerce hook
- Empty Super Cache programmatically (with ACF action) [closed]
- What is the best filter where to use register_block_type?
- How to use do_action_ref_array?
- Admin Hook at the Login Page
- Check if do_action(‘custom_action’) is hooked into?
- How to find hooks as per Just-In-Time approach?
- How To Make Sure That My Action Hook Executes Last
- Does update_comment_meta hook exists?
- how to determine how many and what kind of arguments are passed to hooks
- WP CLI Get all Enqueued Scripts and Styles
- Delay an action until current action is completed
- What’s hook to use immediately after a user is authentcated [duplicate]
- Hooking into the init action will fire it too frequently?
- Event-Driven Pattern vs MVC?
- Insert term when page is published – avoid duplicates after edits
- Implement Hooks Using Array
- Looking for a hook for post.php
- Save User Meta Email Address in Lowercase
- Save acf field data via acf/save_post before post is saved
- How do I trigger a post update within a get_posts() foreach loop?
- Hook when editing user
- Execute JavaScript in WordPress Hook
- schedule event in class oriented plugin
- Add action hook into wp_localize_script
- Hooks are not being removed in child theme
- How to replace a function using a child theme?
- Removing parent theme action on pluggable function not working
- Which action hook should I use to intercept a form upon submission?
- Would there be anything stopping me from removing both wp_head and wp_footer?
- Is it possible to add the_content filter upon login?
- WordPress wp_loaded action hook
- add_action second argument missing
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- admin_notices action doesn’t trigger within save_post action
- I don’t understand how add_action and do_action work in tandem. The former executes the code already…what is do_action for?
- Check if `do_action()` in WordPress returns any result
- How to cancel an action hooked to untrash_post? or any hook
- Add Different Actions To Different Page’s wp_footer
- What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?
- add_action hook for publish_post not working
- How to run a function after wp() in the wp-blog-header.php file?
- Hook for inserting?
- Notify admin when Custom post meta data gets updated or deletet
- How to change a WordPress term’s slug before saving
- dynamic add_action according to child pages (for homepage control)
- Remove action in a parent theme from the child theme
- Remove action within a class in a parent theme’s includes folder from the child theme
- Remove genesis_404 hook from genesis_loop [closed]
- Add html code in admin page
- Action hook with wrapper html
- What hook to add at start of WordPress load
- A good hook to check authorization and redirect?
- Adding custom Bulk Actions
- What hook to use to redirect based on $post
- Is there a author_update action?
- Change status of page after an event (Looking for best practice advice)
- Post via wp-admin and via iOS app, same hooks and triggers involved?
- Hooking save_post breaks check for term in added_term_relationship hook?