{"id":3349,"date":"2009-08-11T04:55:13","date_gmt":"2009-08-11T11:55:13","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=3349"},"modified":"2009-08-11T04:56:26","modified_gmt":"2009-08-11T11:56:26","slug":"loginlogout-and-user-welcome","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/wordpress\/loginlogout-and-user-welcome\/","title":{"rendered":"Login\/Logout and User Welcome"},"content":{"rendered":"
<div id=\"user-details\">\r\n<?php\r\n   if (is_user_logged_in()) {\r\n      $user = wp_get_current_user();\r\n      echo \u2018Welcome back <strong>\u2019.$user->display_name.\u2018<\/strong> !\u2019;\r\n   } else { ?>\r\n      Please <strong><?php wp_loginout(); ?><\/strong>\r\n      or <a href=\"<?php echo get_option(\u2019home\u2019); ?>\/wp-login.php?action=register\"> <strong>Register<\/strong><\/a>\r\n<?php } ?>\r\n<\/div><\/code><\/pre>\n

Uses WordPress functions and queries to pull user information, and to display the login\/logout\/register links.<\/p>\n","protected":false},"excerpt":{"rendered":"

<div id=”user-details”> <?php if (is_user_logged_in()) { $user = wp_get_current_user(); echo \u2018Welcome back <strong>\u2019.$user->display_name.\u2018<\/strong> !\u2019; } else { ?> Please <strong><?php wp_loginout(); ?><\/strong> or <a href=”<?php echo get_option(\u2019home\u2019); ?>\/wp-login.php?action=register”> <strong>Register<\/strong><\/a> <?php } ?> <\/div> Uses WordPress functions and queries to pull user information, and to display the login\/logout\/register links.<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3229,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":18728,"url":"https:\/\/css-tricks.com\/lodge\/v10\/149-building-a-login-form-for-the-lodge\/","url_meta":{"origin":3349,"position":0},"title":"#149: Building a Login Form for The Lodge","date":"October 2, 2012","format":false,"excerpt":"One of the reasons WordPress is awesome is that it comes with its own fully functioning user authentication system. Writing that from scratch these days would be pretty dumb if you don't plan to bring a heaping pile of innovation to the process. Restrict Content Pro, our membership plugin, of\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4278,"url":"https:\/\/css-tricks.com\/snippets\/php\/login-function\/","url_meta":{"origin":3349,"position":1},"title":"Login Function","date":"September 29, 2009","format":false,"excerpt":"These functions will log in a user based on a username and password being matched in a MySQL database. \/\/ function to escape data and strip tags function safestrip($string){ $string = strip_tags($string); $string = mysql_real_escape_string($string); return $string; } \/\/function to show any messages function messages() { $message = ''; if($_SESSION['success']\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3446,"url":"https:\/\/css-tricks.com\/snippets\/javascript\/detect-javascript-onoff-with-notification\/","url_meta":{"origin":3349,"position":2},"title":"Detect Javascript On\/Off, With Notification","date":"August 19, 2009","format":false,"excerpt":"JavaScript is off. Please enable to view full site. If JavaScript is on the user gets a welcome message. If off, the user is instructed to turn it on.","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5340,"url":"https:\/\/css-tricks.com\/snippets\/php\/append-login-credentials-to-url\/","url_meta":{"origin":3349,"position":3},"title":"Append Login Credentials to URL","date":"January 20, 2010","format":false,"excerpt":"The example here is if you had a form on a website that when submitted, needed to use that information to go to a special URL where the login information was all appeneded to the URL. You could have the form post with method GET, but that is limited to\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18700,"url":"https:\/\/css-tricks.com\/lodge\/v10\/135-forums-wrangling-part-3-login\/","url_meta":{"origin":3349,"position":4},"title":"#135: Forums Wrangling, Part 3, Login","date":"October 2, 2012","format":false,"excerpt":"We keep digging into theming the Forums area of the site. We've done good so far, but the deeper we dig the more difficult things are going to get. Partially just because I don't have a ton of experience with Vanilla Forums and partially because it's just kinda weird! We're\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18734,"url":"https:\/\/css-tricks.com\/lodge\/v10\/152-styling-the-wordpress-lodge-login-page\/","url_meta":{"origin":3349,"position":5},"title":"#152: Styling the WordPress (Lodge) Login Page","date":"October 2, 2012","format":false,"excerpt":"Our \"widget\" for The Lodge in the sidebar of the site (shows on most pages, including homepage) has two states. One for when a user is logged out and one when a user is logged in. The logged out state has a login form right on it so current members\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3349"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=3349"}],"version-history":[{"count":3,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3349\/revisions"}],"predecessor-version":[{"id":3352,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3349\/revisions\/3352"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3229"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=3349"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=3349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}