Add Logout Button to Password Protected WordPress Posts

Have you noticed there is no logout button or link on password 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 … which means simply closing the browser does not logout users!

password protected pages

Anyone Can Access Private Posts!

password postsWebmasters 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 –  but 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  a password!

While clearing the browser cache and all cookies helps to deal with this issue – how many times will your site visitors clear their cache.  Rarely.

How to Add Logout Button

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.  We use the Protected posts logout button plugin. It works in one click to add a logout button automatically to all protected posts.

The settings options allow you to add a CSS class to the button, so that you can customize the button look. Remember to force CSS refresh the right way.

logout settings

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.

.btn-logout {
float: right;
padding: 20px;
background: green;
color: white;
text-transform: uppercase;
border-radius: 10px;
border: 1px solid #333;

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 this logout button by default on these protected posts.


  1. Arun Kallarackal says:

    Well, that was a serious issue that one faced in the case of accessing restricted content. Yes, the condition is much severe in the case of public computers. Users, if unable to log out, will carelessly close it and leave. But the cookies will ensure that the session can ce resumed upon re opening the browser!

    The solution provided will ensure that the log out button is present at a prominent location, in front of the visitors’ sight. A handy guide indeed!

  2. Karen Tu says:

    Yes, I agree with you. It is really important for my wordpress blog. I apply now for my site and thanks for your sharing.

  3. International School Jobs says:

    I’ve been browsing online from more time, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all webmasters and bloggers made good content blog and article as you did, the internet will be much more useful than ever before.

  4. Trivedi Jay says:

    Great tips ; Thanks for sharing this tips with us. Keep sharing and posting new tricks and tips for WordPress.

Leave a Reply

Your email address will not be published. Required fields are marked *