1

Exactly when is a user's meta data loaded? I'm using many get_user_meta() calls for the current user. If all of a logged in user's meta data is loaded anyway, then this type of call is not a problem.

1 Answer 1

0

This page gives you a typical wordpress load http://codex.wordpress.org/Plugin_API/Action_Reference

You can see, the current user is available after the theme is setup but before init. If you are calling these functions within the theme then you will be fine. Otherwise make sure any functions that reference the current user are called using hooks that run after the set_current_user hook. The best hook to use will vary depending on the specifics of what you're trying to do.

4
  • I want to run a function on every pageload to check the current user's metadata. Function must run on front-end and admin pages. What is the best hook to use for this?
    – Henrik
    Mar 5, 2015 at 16:41
  • What does the function do? Mar 5, 2015 at 16:44
  • It get's the current user's meta data key 'foobar' and updates it depending on the value of the key.
    – Henrik
    Mar 5, 2015 at 17:00
  • Your best bet is wp_loaded, it runs on all page types and you'll have access to pretty much all wordpress functions. Mar 5, 2015 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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