Forum

Thread tagged as: Question, Addons, Members

Restrict page to multiple member tags

Is it possible to restrict a page to multiple member tags? For example I have 3 membership levels on a site and want to restrict certain pages to specific levels. Some of the pages need to be visible to all members but remain restricted to logged in members and not visible to those not logged in.

Phil Bowell

Phil Bowell 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can set the tags in the page details tab.

Are they comma separated?

I have applied three tags for a particular page it shows up for none of the test accounts.

What I mean is. I have member, rep and leader levels. I have a page which I want to be visible to all 3 levels and have applied the three tags to the page. It does not show up in the navigation group (despite being in the correct group) when I am logged in as a test account which has one of those tags applied. And when I try to visit the page it redirects me as if I am not logged in.

In the future there will also be a default account level and it's important that these pages are not visible by that level account.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, they're comma delimited.

Have you logged out and back in since changing the member's privileges?

Thanks Drew. I have them as comma delimited (member, rep, leader) and have logged out and then back in but the pages do not appear on any level apart from member. If I log out and try to visit the pages they tell me I need to be logged in, as I would expect.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does the debug output?

When I try to visit a page which has the three tags applied it redirects and the debug output is this


Debug Message SELECT * FROM perch2_members_sessions WHERE sessionID='2a2ecb5f2fe75463bc28fc2625a93d95be90ec96' AND sessionHttpFootprint='4050306420e2698e2dd7e01c617c996a9b5b0977' AND sessionExpires>'2015-08-26 18:13:58' LIMIT 1 User is logged in SELECT * FROM perch2_pages WHERE pagePath='/members/login.php' LIMIT 1 SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members/login.php' LIMIT 1 SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-011-011', '000-011', '000') Using template: /templates/navigation/item.html SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/login.php' OR regionPage='*' ORDER BY regionPage DESC SELECT groupID FROM perch2_navigation WHERE groupSlug='members' LIMIT 1 SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=2 ORDER BY np.pageTreePosition ASC SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/members/login.php' LIMIT 1 Using template: /templates/navigation/item.html

When logged out and I try to visit the same page I get this

Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/members/login.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members/login.php' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-011-011', '000-011', '000')
Using template: /templates/navigation/item.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/login.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/members/login/login_form.html

In both instances the url's look like this: /members/login.php?r=/members/oprp.php I requested: /members/oprp.php

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm yes, it's really the debug from /members/oprp.php I need.

I figured it would be, but I can't access it with the tags applied to give you the debug. This is the debug with tags removed:


Debug Message SELECT * FROM perch2_members_sessions WHERE sessionID='ac1917d2c84d4954c8e6c2f135986113399ce3a0' AND sessionHttpFootprint='4050306420e2698e2dd7e01c617c996a9b5b0977' AND sessionExpires>'2015-08-27 14:34:14' LIMIT 1 User is logged in SELECT * FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1 SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1 SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-011-003', '000-011', '000') Using template: /templates/navigation/item.html SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/oprp.php' OR regionPage='*' ORDER BY regionPage DESC SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='OPRP' AND (regionPage='/members/oprp.php' OR regionPage='*') SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=77 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC Using template: /templates/content/oprp_listing.html SELECT groupID FROM perch2_navigation WHERE groupSlug='members' LIMIT 1 SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=2 ORDER BY np.pageTreePosition ASC SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/members/oprp.php' LIMIT 1 SELECT pageID FROM perch2_navigation_pages WHERE groupID=2 AND pageTreePosition IN ('000-003', '000') Using template: /templates/navigation/item.html

and this is it with one tag applied

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='ac1917d2c84d4954c8e6c2f135986113399ce3a0' AND sessionHttpFootprint='4050306420e2698e2dd7e01c617c996a9b5b0977' AND sessionExpires>'2015-08-27 14:35:38' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-011-003', '000-011', '000')
Using template: /templates/navigation/item.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/oprp.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='OPRP' AND (regionPage='/members/oprp.php' OR regionPage='*')
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=77 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC
Using template: /templates/content/oprp_listing.html
SELECT groupID FROM perch2_navigation WHERE groupSlug='members' LIMIT 1
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=2 ORDER BY np.pageTreePosition ASC
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/members/oprp.php' LIMIT 1
SELECT pageID FROM perch2_navigation_pages WHERE groupID=2 AND pageTreePosition IN ('000-003', '000')
Using template: /templates/navigation/item.html

If you can advise how I could get some debug with all the tags applied I'd be more than happy to follow it.

Edit: I've tried various different methods to get it to work. It seems that which ever tag is first in the list is the one that works but the others don't.

This is the debug with all tags applied and viewed with an account with the first tag applied.

Debug Message
SELECT * FROM perch2_members_sessions WHERE sessionID='ac1917d2c84d4954c8e6c2f135986113399ce3a0' AND sessionHttpFootprint='4050306420e2698e2dd7e01c617c996a9b5b0977' AND sessionExpires>'2015-08-27 14:37:05' LIMIT 1
User is logged in
SELECT * FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members/oprp.php' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-011-003', '000-011', '000')
Using template: /templates/navigation/item.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members/oprp.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='OPRP' AND (regionPage='/members/oprp.php' OR regionPage='*')
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=77 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval ASC
Using template: /templates/content/oprp_listing.html
SELECT groupID FROM perch2_navigation WHERE groupSlug='members' LIMIT 1
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=2 ORDER BY np.pageTreePosition ASC
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/members/oprp.php' LIMIT 1
SELECT pageID FROM perch2_navigation_pages WHERE groupID=2 AND pageTreePosition IN ('000-003', '000')
Using template: /templates/navigation/item.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

I would expect that to work. I'll run some tests next week and see what I can find.

Thanks Drew, I really appreciate you looking into it.

Hi Drew, I wondered if you'd managed to look into this. I'm still seeing the odd behaviour with the multiple tags applied to a page.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I've not managed to get to the bottom of it yet, but it's still ongoing.

I've hit the same snag too.