سؤال

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??

هل كانت مفيدة؟

المحلول

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';
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top