How to check user role without using current_user_can()

You could check the $current_user variable to determine the role.

I believe it should be realiable after init(maybe even on init) for a logged in user, a guest visitor obviously won’t have any data associated with him or her yet(so it’ll be empty/unset).

You can also call up get_currentuserinfo() to populate the $current_user var, but i’ve personally never found a need when calling $current_user after init(but i’m sure there may be cases when you need to call it, so it’s linked below for reference).

http://codex.wordpress.org/Function_Reference/get_currentuserinfo

Leave a Comment