Thứ Tư, 24 tháng 2, 2016

How to adding private pages

When we went through the requirements for the site, you'll remember I said I wanted to make certain sections of the site private, so only registered users could see them. And that includes all this guest information, the guest info page, the RSVP page, the hotels page, and the what to wear page. Now this requires several steps. First I have to make those pages private. Then I have to make a group that can have access to the pages. Then I have to grant that group access to the pages. And then I have to make some way for my guests to register on the site so that they can gain access to this information.

And we'll start out by making the pages private. If we go to the back end of WordPress, and go to pages, and go to one of the pages, so guest info, I can make the page private right from within this editor. By making a page private, what I'm saying is, only the creator of this page will be able to see it on the front end. And I know that sounds weird, because I just said that we're gonna let all our guests access this page, but we're gonna change that later on. But the private feature is something that's built into WordPress core, and we're gonna use it for this particular purpose as we build out the site.

To change the status of this page, I now need to go to visibility, which is currently set to public, meaning anyone can see it, click edit and change it to private. When I click OK and update this page, I can still see the page because I'm logged in as myself. It says "Private: Guest Info." However, if I grab the URL and go and open an incognito window of my browser so I'm no longer logged in, and then try to visit that same URL, I end up with a 404 page, meaning this page does not exist.

In fact, if I click on guest info, you'll see I keep getting a 404 message. But if I click on any of the other pages, I'm taken directly to whatever page that is. So although this looks pretty weird right now, this is exactly what I want. I wanna make these pages private so they're only available to logged-in users. Now you could also do this in bulk. So if I go back to my dashboard, and go to pages, I can check off all the pages I want to become private. So hotels, RSVP, and what to wear. And then I'll go to bulk actions and click edit, and apply.

And from here I can change the status of all these three pages at once. So I'll change them all to private. Click update. The new status of each of these pages is now reflected in my lists, you see they're all private, and if I jump back to my incognito browser, and try to navigate to any one of them, I now get that same 404 page telling me there's nothing here. Now like I said, this is step one. Right now, everything is pretty weird. I'm redirecting guests to a 404 page and I'm the only person who can access these pages.

So in the next couple of movies, we'll use plugins to change all of that.

Không có nhận xét nào:

Đăng nhận xét