How to check login status in wordpress

Using “is_user_logged_in” function You can check user login or not.

e.g

<?php if(is_user_logged_in()): ?>

echo “Insert your HTML or PHP code here”;

<?php else:

wp_die(‘Sorry, you must first <a href=”/wp-login.php”>log in</a> to view this page. You can <a href=”/wp-login.php?action=register”>register free here</a>.’);

endif; ?>


To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

Share This Post

Related Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie