0

I am relatively new to Wordpress and I recently moved a WordPress website from one domain to another. I went through and fixed all the links and references that I could find. Now my website has all of its previous functionality, even the databases are working. The only issue that is for some reason the is_user_logged_in() function always returns false. I had this code to restrict users from viewing a page unless they were logged in:

if ( is_user_logged_in() ) {
   // logged in code 
 } else {
  // logged out redirect
 }

It always goes to the else statement regardless. Oddly, I can see that I am logged in since the log out button appears and when I am logged in as admin the top panel is visible. There are lots of other threads about this online but none of their methods seems to work. I have read and tried methods suggested in these posts:

https://stackoverflow.com/questions/19946972/wordpress-check-if-user-is-logged-in https://wordpress.org/support/topic/is_user_logged_in-not-working-as-expected https://core.trac.wordpress.org/ticket/14609

Is there some other reference I need to fix? How can I do it? Any help is greatly appreciated.

  • Have you tried clearing your browser cookies? If so and it didn't work, please try disabling all plugins, and if that still fails revert to the original theme and add a little test code to functions.php to test is_user_logged_in(). If this fixes your problem, try switching back to your theme and then enabling the plugins one at a time to isolate the offending theme/plugin. – David Gard Feb 2 '15 at 9:33
  • Thanks for the reply, I already tried disabling plugins which didn't work. I just cleared my browser and tried again which also did not have any effect. Do you have any other suggestions? – klib Feb 2 '15 at 14:32

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.