Support » Fixing WordPress » retrieving user_ID in a plugin

  • I’ve gone over every related post on here as well on the wp-hackers mailing list and need some advice, please.

    I am trying to populate the $user_ID variable for inclusion inside an http_get request that currently exists inside a function. Knowing that I cannot use get_currentuserinfo() because pluggable.php isnt loaded, I tested seeing what would happen if tied that fucntion to a hook, in this case, init. As i expected, get_currentuserinfo() works, and the variable is populated, but because Ive tied the function into init, its submitting data the minute the plugin is loaded, without the http_get even being called.

    I’ve read a cpl references to setup_userdata() on here, seen one example, which doesnt work for me in this case.

    So here is my question.

    How can I populate the $user_ID variable without tying it to a hook?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried:

    global $user_ID;

    before its inclusion in your code? It’s a global var that’s available in many many places by default.

    yes.

    at this point Im ready to replicate get_currentuserinfo() right into the plugin, out of frustration.

    any luck with this? i’ve built an admin menu plugin but can’t access the user_id through any means yet posted. my plugin is hooked to ‘admin_menu’. i know pluggable hasn’t been called yet.. but is there anyway to replicate the get_currentuserinfo() at the ‘admin_menu’ point? is there another option?

    any help would be appreciated.. thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘retrieving user_ID in a plugin’ is closed to new replies.