How to check if user logged in or not in wordpress?

check-if-user-logged-in-or-not

Function: is_user_logged_in()

This Conditional Tag checks if the current visitor is logged in. This is a boolean function, meaning it returns either TRUE or FALSE.

Checks if the current visitor is logged in and returns True if user is logged in, false if not logged in.

Example

<?php
if ( is_user_logged_in() ) {
//your logic here
    echo 'Welcome, registered user!';
} else {
    echo 'Welcome, guest!';
}
?>

Reference

http://codex.wordpress.org/Function_Reference/is_user_logged_in