Marty Walker Posted August 9, 2013 Share Posted August 9, 2013 Hi everyone, I'm working on a site that gives users access to parts of the site. It goes something like this: - Your Pages -- Seminar 1 --- seminar page 1 --- seminar page 2 -- Seminar 2 --- seminar page 1 --- seminar page 2 ... and so on On the Seminar 1 & Seminar 2 pages I have a field called 'Allowed users' which is a Page field that looks at the admin/access/users page. I have it setup to display all the users as checkboxes. I thought that I might have built an easy way for the admin to add selected users to each Seminar but I'm having trouble. What I'm trying to do is match the logged in user with the checked username on the Seminar 1 & Seminar 2 pages and a) only show that user the seminars they have access to and b) all the pages below that belong to that seminar. They're going to have quite a few seminars. Getting them to setup a Role for each seminar and then adding that role to each user would be quite tedious. I haven't done much with user management at all in PW. Any ideas on how I might approach this? Is there a better way? Regards Marty Link to comment Share on other sites More sharing options...
kongondo Posted August 9, 2013 Share Posted August 9, 2013 The following could be of use? Scroll down for ideas about checking user... http://processwire.com/talk/topic/4116-best-way-to-structure-a-classifieds-site/ Link to comment Share on other sites More sharing options...
Wanze Posted August 9, 2013 Share Posted August 9, 2013 Hi Marty, What trouble do you have? Let's say Seminar1 and Seminar2 both have the same template. If a user visits those sites, you should be able to do a check like this: // Check if the current user can access this seminar page if ($page->allowedUsers->has($user)) { // Good! List the Seminar children } else { throw new Wire404Exception(); } ... where allowedUsers is your Page field (checkboxes) for the users. Of course you'd need also to check on the seminar subpages, so that a user can't access them directly: if ($page->parent->allowedUsers->has($user)) { // Good! } else { throw new Wire404Exception(); } 6 Link to comment Share on other sites More sharing options...
Marty Walker Posted August 11, 2013 Author Share Posted August 11, 2013 Thanks Wanze, has($user) did the trick. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now