Support » Plugins » Hacks » Function Reference/is user logged in not working

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hmm

    1) – it’s a pluggable function – any other plugins altering the function?

    2) it just checks :

    $user = wp_get_current_user();
    	if ( $user->id == 0 )

    try doing $user = wp_get_current_user(); yourself and dumping $user to see what is going on?

    are you calling it in exactly the same place?

    Anmari, Thank you. I tried this

    $user = wp_get_current_user();
    $userid = $user->id;
    echo "User ID: " . $userid;

    But this always returns the “User ID: 0” even if I am logged in.

    My guess is this is an error caused by having my WordPress installation in a subfolder called “CMS” has the session cookies all have the path /CMS/ Next I will try moving my installation to the root.


    Hi, I don’t think that’s it.

    I don’t think wordpress uses sessions? and Many of my sites are in a sub folder and I have had no problem with that. WordPress itself uses that function all over the place.

    Maybe somehow it thinks you aren’t logged in yet? Page definitely refreshed after logon?

    what is the wp version? Do you have admin bar functionality? Switch on for front end and check whether it is displayed at the top ?

    The meta widget will also change if wp thinks you are logged in – drag it to the sidebar of the page where your code is and check that when you are logged in it says “logout”

    Thanks. I tried adding the meta widget as you suggested. It shows “login” even if I am logged in.

    In Firefox, if I delete the cookies for my site, and sign in, then there are new cookies. What makes me think having the installation in a subfolder is the problem is that the cookies show the path of the installation folder, not of the public side of the site.

    I will try moving my installation to see if that helps.


    I moved my WP installation to the root rather than the subfolder CMS, and that worked. The cookies had the path /cms/ before the move, and now they have the path / which has fixed the problem.

    I consider this a bug in WordPress, since putting your installation in a subfolder causes core functions to stop working.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Function Reference/is user logged in not working’ is closed to new replies.