Support » Developing with WordPress » is_user_logged_in() ALWAYS returns false

  • Resolved danhgilmore


    I have a custom login plugin that I use for my installation. This runs every time a page is loaded. If the user is logged in, get out of the plugin.

    Unfortunately, no matter what, is_user_logged_in() always returns false, thus forcing the user to log in each and every time a page is loaded. Any ideas?

    function my_func(){
      if (is_user_logged_in())
        // User is logged in, so get out of this plugin.
      // LOG THE USER IN.
    add_action( 'init', 'my_func' );

    I think it has something to do with $current_user being defined incorrectly, as seen in the link

Viewing 1 replies (of 1 total)
  • Thread Starter danhgilmore


    So it turns out that is_user_logged_in() will return FALSE if you are not using the correct protocol. I have my FQDN listed in wp-config.php as https://localhost/ and I was troubleshooting with http://localhost/

    When I debugged with HTTPS, it worked as intended.

Viewing 1 replies (of 1 total)
  • The topic ‘is_user_logged_in() ALWAYS returns false’ is closed to new replies.