Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to make pages like Groups, Forums, members and updates only accessible to members?


Ben
Participant

@bgiddings

I think @pcwriter‘s code is the way to go – it’s just a question of putting it in the right files according to what you want to block. EG I wanted to block access to member profiles if user is not logged in, but I wanted them to see all the rest of the content on my site. So I copied the following files to my child theme:

members – single – home.php
members – single – member-header.php

Then in home.php I added the “is user logged in” check as shown highlighted here: http://pastebin.com/EyhRuwCq

This stopped the main profile content from appearing if the user is not logged in. You could stop there, but I wanted to remove extra data from the profile header and leave a message to the un-logged in user. So in header-message.php I added the log-in check as highlighted here: http://pastebin.com/mpxbkcCe

This cuts out all content in the header apart from the gravatar, the member name and a polite message. You can see it here: http://www.thebookboard.com/members/bookboard/

I’m not a coder, so I make no guarantees that this will work in all circumstances, but it works for me. Hope it helps others

Skip to toolbar