get_terms() returns an empty array when called from delete_user action hook
-
When calling:
get_terms('post_tag', array('hide_empty' => 0));
from action hooks:
delete_user
deleted_user
wpmu_delete_user
What’s being returned is an empty array. When calling the same code from different action hooks, a proper non-empty array is being returned. Happens with
post_tag
,category
and any custom taxonomy regardless of whether or not terms are empty or associated to posts.Original code:
function get_terms_test($user_id) { // get terms $terms = get_terms('post_tag', array('hide_empty' => 0)); // also tried other non-empty taxonomies echo var_dump($terms); // also tried count(); die(); } add_action('delete_user', 'get_terms_test'); // also tried the other hooks mentioned
Any ideas why?
- The topic ‘get_terms() returns an empty array when called from delete_user action hook’ is closed to new replies.