1if ( is_user_logged_in() ) {
2 // your code for logged in user
3} else {
4 // your code for logged out user
5}
1<?php
2if ( is_user_logged_in() ) {
3 echo 'Welcome, logged in user. <a href="'.wp_logout_url().'">Click here to logout</a>.';
4}else{
5 echo 'Please login by <a href="'.wp_login_url().'">clicking here</a>.'
6}
1<?php
2add_action('admin_init', 'wpse74389_check_username');
3function wpse74389_check_username()
4{
5 $user = wp_get_current_user();
6
7 if($user && isset($user->user_login) && 'username_to_check' == $user->user_login) {
8 // do stuff
9 }
10}
11