I want to do some stuff when a category is created the only hook i could find is
add_action( 'edited_category' , 'custom_term_saved', 10, 2 );
but it is only called on edit form saved not on create form saved
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI want to do some stuff when a category is created the only hook i could find is
add_action( 'edited_category' , 'custom_term_saved', 10, 2 );
but it is only called on edit form saved not on create form saved
There is a hook that can be used for any taxonomy, create_{$taxonomy}
, which in your case, is a category. So, it would be create_category
:
add_action( 'create_category', 'my_function', 10, 1 );
This is triggered by wp_insert_term()
at line 2142.