Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 3 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.

<?php
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
add comment

Your Answer

 
discard

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.