I created a custom taxonomy organization for users and I could get specific organization user list by using get_objects_in_term($term_id, $taxnomy_name) functions. But, I can't use get_objects_in_term($term_id, $taxnomy_name) while deleting term with these below action

do_action( 'delete_term_taxonomy', $tt_id );
do_action( 'deleted_term_taxonomy', $tt_id );
do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term );
do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term );

My question "Is there any ways to get user list from specific organization before deleting that organization?"


Use the pre_delete_term hook, which fires before the actual deleting occurs, so the relationships will still be present.

function wpse_296972_pre_delete_term( $term_id, $taxonomy_name ) {
    if ( $taxonomy_name === 'organization' ) {
        $objects = get_objects_in_term( $term_id, $taxonomy );

        // Do something with $objects.
add_action( 'pre_delete_term', 'wpse_296972_pre_delete_term' );
  • I didn't know that action exist. I sent 4 hours for that. Big Thanks, Man – por Mar 16 '18 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.