473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to password protect wordpress site?

I need to password protect my wordpress site except home page. I need homepage to be visible to every visitor but if they click on ANY link that could be post/page within the site then user should be redirected to login page. Any help would be appreciated
Nov 29 '10 #1

✓ answered by Mayur2007

Hello rizwanrajput,

Just try with the following function.

Expand|Select|Wrap|Line Numbers
  1. function password_protected() {
  2.     if(!is_home() or !is_front_page()) {
  3.         if ( (!is_user_logged_in() and !is_feed()) or (!is_user_logged_in() and is_feed() and !get_option("wppassprotect_public_feed")=="checked ")) {
  4.         auth_redirect();
  5.         }
  6.     }
  7. }
  8.  

Thanks & Regards,
Mayur Bhayani

4 2485
dlite922
1,584 Expert 1GB
Wordpress manual shows you how to do this. Have you read it?

Dan
Nov 29 '10 #2
Hello,

You can make your page / post password protected from the admin panel >> Edit Page/Post then click on visibility Edit link from right sidebar and set restriction and click on ok button.
Hope your problem will be solved.

Regards,
Mayur Bhayani.
Nov 30 '10 #3
I don't want to do that. I have a website with around 10 pages. I only want to display home page to visitors and rest of the pages should be visible to logged in users only. If a visitor tries to access another page they should be redirected to login page. I just installed a plugin PASSWORD PROTECT PLUGIN FOR WORDPRESS. It is redirecting visitors to login form for all pages including home page. I want to display home page to visitors. This is the code :

function password_protected() {
if ( (!is_user_logged_in() and !is_feed()) or (!is_home() and !is_front_page()) or (!is_user_logged_in() and is_feed() and !get_option("wppassprotect_public_feed")=="checked ")) {
auth_redirect();
}
}

In this code, I added (!is_home() and !is_front_page()) myself to allow visitors to see home page but it's not working. Am I doing something wrong?
Nov 30 '10 #4
Hello rizwanrajput,

Just try with the following function.

Expand|Select|Wrap|Line Numbers
  1. function password_protected() {
  2.     if(!is_home() or !is_front_page()) {
  3.         if ( (!is_user_logged_in() and !is_feed()) or (!is_user_logged_in() and is_feed() and !get_option("wppassprotect_public_feed")=="checked ")) {
  4.         auth_redirect();
  5.         }
  6.     }
  7. }
  8.  

Thanks & Regards,
Mayur Bhayani
Nov 30 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Narlen | last post by:
Hi there, I don't know much about web design but I proudly managed to password protect a page on my site. Later I realized that everyone looking at the source in any web browser can see the...
5
by: Brent Burkart | last post by:
I want to protect my website with a user and password. I have SQL Server 2000 where I want to store the users and passwords and the website is complete. I just need to add in some security with...
1
by: Tim Zych | last post by:
How do I password protect my asp.net site, or a folder within it?
4
by: Tim Zych | last post by:
I want to password protect my site. In order to access it, one would have to login with a username and password. How can I do that?
4
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication...
5
by: Trev | last post by:
Hey, I have a complete frontend setup, the first window/form that shows up gives you an option of 3 databases. One of them will only need to be accessed by about 2 - 3 people within our...
3
by: Miro | last post by:
Why Password protect an MDB when someone can google and get a hack? Wondering if anyone else has thought of this and just said "oh well"... I plan to password protect an MDB where I have some...
12
by: =?Utf-8?B?am9uaWdy?= | last post by:
I wrote a simple VB.NET application that imports and edits CSV files. Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be opened separately. It is not high-sensitive...
22
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
16
by: Greg (codepug | last post by:
If one converts that .mdb into an .mde the code is secure but the tables can still be imported. Just for Very Basic protection, I have placed a Password on the database using the "Set Database...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.