1

I am building a theme switcher, that needs to block access to not logged in and subscriber users. Problem is that this has to be done in a function that is called at the "setup_theme" phase/hook, and wp_get_current_user etc. is not yet available at that point.

Is there a workaround to check if someone is logged in at this pre-init phase, and what the capabilities of this person are?

Regards, Joost.

  • 1
    Are you sure? I just called $current_user = wp_get_current_user(); on a setup_theme action and it returned all the current user info. – David Labbe Jun 15 '15 at 13:08
  • You are right. The problem was a change in the wp-config.php that redirected to the main domain. I tried to log in on the subdomain and was subsequently redirected to the main domain. So the script was right. I was not logged in and it rightly denied me acces :-) Thanks for your help. – jberculo Jun 15 '15 at 13:43

Your Answer

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

Browse other questions tagged or ask your own question.