[wp-hackers] getting current user info

Travis Snoozy ai2097 at users.sourceforge.net
Thu Nov 8 18:56:55 GMT 2007


On Thu, 8 Nov 2007 10:14:53 -0800, "Lloyd Budd"
<lloydomattic at gmail.com> wrote:

> On 11/8/07, Travis Snoozy <ai2097 at users.sourceforge.net> wrote:
> > On Thu, 8 Nov 2007 10:37:22 -0700, "Mindshare Studios"
> > <info at mindsharestudios.com> wrote:
> >
> >
> > > I could be barking up the wrong tree entirely. Any suggestions?
> >
> > You're thinking too hard. ;)
> >
> > global $current_user;
> > $current_user->user_email;
> >
> > Make sure you're doing it after authentication has taken place,
> > though.
> 
> I recently used just this and it is as easy as Andy and Travis suggest
> -- bummer is knowing what to look for, but I found similar code in
> another plugin (don't recall which one now).
> 
> http://codex.wordpress.org/Function_Reference/get_currentuserinfo

get_currentuserinfo is only needed if you're doing stuff really,
really early. When wp() is called, get_currentuserinfo is called
automatically; any filters/actions that are used after the wp action
just need to use the globals (it's been that way since 2.0). There are
only a tiny handful of actions that you can hook that *won't* have the
global data already set (most notably, plugins_loaded and init).


-- 
Travis 

In Series maintainer
Random coder & quality guy
<http://remstate.com/>


More information about the wp-hackers mailing list