[wp-hackers] checking for user logged in a plugin
Sergey Biryukov
sergeybiryukov.ru at gmail.com
Mon Apr 30 05:30:28 UTC 2012
On Fri, Apr 27, 2012 at 5:59 PM, Lionel POINTET
<lionel.pointet at globalis-ms.com> wrote:
> On 27 Apr 2012, at 8:41:43AM, Chris McCoy wrote:
>
> > Im doing this in a plugin
> >
> > if(is_user_logged_in() && current_user_can('administrator')) {
> > add_filter('stylesheet', 'admin_role_theme');
> > add_filter('template', 'admin_role_theme');
> > }
> >
> > But fires is_user_logged_in not defined, should I be firing this a
> diferent
> > way.
>
> This function is defined in the pluggable.php file, which is included
> *after* the plugins, since this is designed to be overwritten by them.
> So you have to wrap your code in a function that could be called on the
> 'plugins_loaded' hook for example.
Note that current user is set up later, so 'init' would be the correct
hook here:
http://core.trac.wordpress.org/browser/tags/3.3.2/wp-settings.php#L294
More information about the wp-hackers
mailing list