{"id":74369,"date":"2012-03-19T08:49:06","date_gmt":"2012-03-19T12:49:06","guid":{"rendered":"http:\/\/wpmu.org\/?p=74369"},"modified":"2012-11-20T15:25:57","modified_gmt":"2012-11-20T20:25:57","slug":"daily-tip-how-to-check-if-a-wordpress-user-is-logged-in","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/daily-tip-how-to-check-if-a-wordpress-user-is-logged-in\/","title":{"rendered":"How to Check If a WordPress User is Logged In"},"content":{"rendered":"<p>Here&#8217;s a quick tip for showing different content with WordPress based on whether a user is logged in or not. You can replace the text with an image or link or anything you like. Use it in your sidebar, header, footer or any template in your theme where you want to display content conditionally.<\/p>\n<p>{code type=php}<br \/>\n<?php\nif ( is_user_logged_in() ) {\n    echo 'Welcome, registered user!';\n} else {\n    echo 'Welcome, visitor!';\n};\n?><br \/>\n<\/code><\/p>\n<p>This snippet comes to you courtesy of our friends at <a href=\"http:\/\/wp-snippets.com\/check-if-user-is-logged-in\/\" target=\"_blank\">WP-Snippets<\/a>, a great resource for finding WordPress hacks and learning a few new skills. Subscribe to the<a href=\"http:\/\/feeds.feedburner.com\/wpsnippets\" target=\"_blank\"> WP-Snippets feed<\/a> for more useful bits of code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to conditionally display content based on whether or not a WordPress user is logged in or not.<\/p>\n","protected":false},"author":4099,"featured_media":74378,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[],"tutorials_categories":[],"class_list":["post-74369","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/74369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/4099"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=74369"}],"version-history":[{"count":0,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/74369\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/74378"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=74369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=74369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=74369"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=74369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}