Question

I need some help to show specific content for specific user. Expecting something similar to below

if( is_username('john')
{
  $echo 'Welcome john. You are from india.';
} else {
  $echo 'You have no rights to access this page...';
}

it should check condition only by username (text) not by user_id or any integer. Possible??

Was it helpful?

Solution

Use get_currentuserinfo() then compare $current_user->user_login with the username you want to check for.

for example:

get_currentuserinfo()
if($current_user->user_login == 'the_username') {
    echo 'woop';
} else {
    echo 'nope';
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top