WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can you check if specific username is logged in?

share|improve this question
I'd like to use specific css on the admin panel for a specific user. – Shae Nov 29 '12 at 22:31
up vote 4 down vote accepted

wp_get_current_user then compare the object that's returned user_login proprety with the specific username you'd like to check against.

add_action('admin_init', 'wpse74389_check_username');
function wpse74389_check_username()
    $user = wp_get_current_user();

    if($user && isset($user->user_login) && 'username_to_check' == $user->user_login) {
        // do stuff
share|improve this answer
Worked like a charm! thanks – Shae Nov 30 '12 at 23:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.