{"id":40541,"date":"2014-05-02T20:32:43","date_gmt":"2014-05-02T15:02:43","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=40541"},"modified":"2020-05-24T10:54:47","modified_gmt":"2020-05-24T05:24:47","slug":"add-logout-button-to-password-protected-wordpress-posts","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2014\/05\/add-logout-button-to-password-protected-wordpress-posts\/","title":{"rendered":"Add Logout Button to Password Protected WordPress Posts"},"content":{"rendered":"<p>Have you noticed there is no logout button or link on\u00a0password protected posts in WordPress! These posts need a password for visitors to gain access, but there is no way to logout. The browser stores the cookies which lasts over days &#8230; which means simply closing the browser does not logout users!<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-40543\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-protected.png\" alt=\"password protected pages\" width=\"294\" height=\"153\" border=\"1\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-protected.png 294w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-protected-150x78.png 150w\" sizes=\"(max-width: 294px) 100vw, 294px\" \/><\/p>\n<h2>Anyone Can Access Private Posts!<\/h2>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-40542\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-posts.png\" alt=\"password posts\" width=\"167\" height=\"178\" border=\"1\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-posts.png 167w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/password-posts-140x150.png 140w\" sizes=\"(max-width: 167px) 100vw, 167px\" \/>Webmasters use Password Protected posts to provide restricted content to subscribers or allow selected users to gain access to private content. So it is important that these users should have a way to logout from these pages &#8211; \u00a0but there is no way. On public computers this is a huge security issue as anyone can easily browse the history, and access your restricted pages without \u00a0a password!<\/p>\n<p>While clearing the browser cache and all cookies helps to deal with this issue &#8211; how many times will your site visitors clear their cache. \u00a0Rarely.<\/p>\n<h2>How to Add Logout Button<\/h2>\n<p>We have several posts which provide content to restricted users. So it was a good idea to add the logout button to these posts and pages. \u00a0We use the <a href=\"https:\/\/wordpress.org\/plugins\/protected-posts-logout-button\/\" target=\"_blank\" rel=\"noopener noreferrer\">Protected posts logout button<\/a> plugin. It works in one click to add a logout button automatically to all protected posts.<\/p>\n<p>The settings options allow you to add a CSS class to the button, so that you can customize the button look. Remember to <a title=\"How to Force CSS Refresh for WordPress Blogs\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2011\/12\/force-browser-css-refresh\/\">force CSS refresh<\/a> the right way.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-40545\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/logout-settings.png\" alt=\"logout settings\" width=\"427\" height=\"257\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/logout-settings.png 427w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/logout-settings-150x90.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/logout-settings-300x180.png 300w\" sizes=\"(max-width: 427px) 100vw, 427px\" \/><\/p>\n<p>We use this CSS to style the logout button on some of the posts. It places a large green button with white text and floats it to the right of all password protected posts.<\/p>\n<pre><code>.btn-logout {\r\nfloat: right;\r\npadding: 20px;\r\nbackground: green;\r\ncolor: white;\r\nfont-weight:bold;\r\ntext-transform: uppercase;\r\nborder-radius: 10px;\r\nborder: 1px solid #333;\r\n}<\/code><\/pre>\n<p>Try this tip to add logout button to all your protected posts. Till then your private restricted content is at a huge risk. I still wonder why WordPress does not display\u00a0this logout button by default on these protected posts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you noticed there is no logout button or link on\u00a0password protected posts in WordPress! These posts need a password&#8230;<\/p>\n","protected":false},"author":4,"featured_media":40543,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6,7],"tags":[17],"class_list":["post-40541","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","category-security","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/40541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=40541"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/40541\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/40543"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=40541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=40541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=40541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}