Support » Plugins » user_ID not always available to plugins

  • I’m afraid that I’m getting over my head with my grand idea 🙂

    I’ve found that my plugin that I’m hacking (dashboard editor) doesn’t always have the global $user_id available to me…

    yes, yes I do a get_currentuserinfo() first…. what I’m finding is that if I init a function (add_action(‘init’,’func’)) and print the id it’s there… but by the time the real function I need to have an ID on, it’s always populating with an ID of 1 … as if the admin is logged in.

    I’ve cleared cache, rebooted the power-grid, called Bill Gates in his jammies… nothing!

    I did a hack to call the pluggable.php file directly at one time, and that skirted me around the issue in another instance…. but I feel like another man was touching me when I did that… just not right.

    Anyhow, could someone enlighten me on the proper order of plug-ins of how and when the user_id gets populated…. I’ve traced a bit into the code, but I’m still creeped out about that man comment…


Viewing 1 replies (of 1 total)
  • Matt,

    There are two issues here you may want to address. First, it’s $user_ID, not $user_id (PHP identifiers are case-sensitive). Second, you may need to declare $user_ID as a global variable inside your plugin before calling get_currentuserinfo():

    global $user_ID;
Viewing 1 replies (of 1 total)
  • The topic ‘user_ID not always available to plugins’ is closed to new replies.