If you are looking put condition on the basis of user’s login, the you can use the bellow code snippets. This is a simple & easy steps. navigate to your current active wordpress theme folder and open the file where you need to implement these condition in your wordpress theme’s files. Add the below code in your current theme file where you want to check the user login status.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php if(function_exists('wplb_login')) { wplb_login(); } global $current_user; #Get current user details get_currentuserinfo(); #Check user login status if (is_user_logged_in() ) { #display the welcome, Current Logged username echo 'Welcome, '; echo ucwords($current_user->user_login); } else { echo 'Welcome, visitor!'; } ?> |
This is_user_logged_in()
function is located in wp-includes/pluggable.php file.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: how to check user is logged in wordpress, Tip and tricks, wordpress