Support » Installing WordPress » $user_ID unavailable in sidebar.php ?

  • Resolved RangerRoman


    The bigger picture is simply a different looking sidebar for when a user is logged in.

    The problem is that I can’t seem to access $user_ID in my sidebar.php file. I’m stumped.

    I’m using the following two lines to help me figure this out:

    User identity: <?php echo $user_identity; ?><br/>
    User ID: <?php echo $user_ID?><br/>

    When I put them in index.php, they return a value. Even when I put them immediately before <?php get_sidebar(); ?>.

    But inside sidebar.php they return nothing.

    I’m not using any plug-ins.
    Any ideas?


Viewing 7 replies - 1 through 7 (of 7 total)
  • MichaelH


    This function might help: Function_Reference/get_currentuserinfo



    Thanks, but it doesn’t seem to help. I use the following lines:

    User Identity: <?php echo $user_identity; ?><br/>
    User ID: <?php echo $user_ID?><br/>
    User login: <?php echo $user_login?><br/>
    User level: <?php echo $user_level?><br/>
    User url: <?php echo $user_url?><br/>
    User_pass_md5: <?php echo $user_pass_md5?><br/>
    User identity: <?php echo $user_identity?><br/>

    In index.php, right before get_sidebar(), they all have values.

    In sidebar.php, nothing. 🙁




    Make sure to scope the variables as global. Example:

    <?php global $user_identity; echo $user_identity; ?>



    I’ve betrayed my inexperience. Thank you very much for that simple fix.


    This dose not work for me. I put:

    <?php global $user_identity; echo $user_identity; ?>

    in sidebar.php but it gave me nothing. I also tried putting it in index.php nothing happened. But when i putt it in comments.php i get the value.

    Any one got a clue?

    Hmm ok here is some more strange strange stuff. When i put it in the sidebar and go to a post. I can see the value. But when i view the site from the index page the value is gone from the sidebar. Same goes for page. But when searching or browsing an archive the value appears in the sidebar.

    problem solved. a little mix up with subdomain and without the subdomain.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘$user_ID unavailable in sidebar.php ?’ is closed to new replies.