How to check if user logged in or not?


Often many times, you might be searching for the wordpress code which checks if the user logged in or not. Its no brainer and amazingly simple!

There could be at many parts of your site (say in header.php) , you want to show only certain links when the user is already registered and logged in like myaccount, logout page.

Here is the code…

<?1php

1if (is_user_logged_in()) {
code1…..
1}
1else
1{
code2…..
1}

1?>

Refer to is_user_logged_in() function in wordpress site.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s