What is the best way to show page only to members? (Solved)

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Art-art

What is the best way to show page only to members? (Solved)

Post by Art-art »

Hi,

Besides general information for the public, I would like to show certain pages with information to logged in members only. What is the easiest way?
I tried to implement the Captcha module to register members but this seems too complex for me. I also get the feeling that this is a too heavy solution for my needs.

I’m basically looking for a solution for:
• 50-100 users (users need to be manually screened before access is granted so there is no self registration needed, further the set of users is rather stable so I think I can handle it manually)
• Shown information should come from a set of MySQL tables through php.

Any suggestions, examples etc?

Thanks in advance.

Arthur
Last edited by Art-art on Mon Aug 20, 2007 7:50 am, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: What is the best way to show page only to members?

Post by RonnyK »

FrontEndUsers in combination with CustomContent.

The first one makes is possible to have people divided in groups (logged in/ not logged in) and those logged-in can be grouped as well.

CustomContent then makes it possible to show different pages/menu to those groups.

Ronny
Art-art

Re: What is the best way to show page only to members?

Post by Art-art »

Thanks for the directions. I fully deleted the captcha module.
I'm progressing now and will go on this weekend. I'll let you know if I can do what I intended to do.

Regards,

Arthur
davidlanier
New Member
New Member
Posts: 5
Joined: Mon Aug 13, 2007 11:01 pm

Re: What is the best way to show page only to members?

Post by davidlanier »

I'm looking for a way to do pretty much the same thing too.
1- I would like logged in users to see more menu items than if they were not logged in.
2- And if the general public tries to access a members-only page, that access should be denied.

For goal # 1:
This could be accomplished by creating two different menus, then testing for logged in users and showing the appropriate menu.  This seems problematic because the two {menu} tags have to be updated whenever a page is added to the site.
What I would rather do is use a select list that is presented on a page, where I select whether it is public or it should be shown only to these particular groups.

For goal # 2:
I don't know of any way to do this currently.  As far as I know, there are only two states for any page: published and not published.

Any tips would be greatly appreciated.

Also see my post in the Frontend Users group:
http://dev.cmsmadesimple.org/forum/foru ... orum_id=30

I wouldn't mind doing some coding to enhance these features, if someone gets me started in the right direction.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: What is the best way to show page only to members?

Post by calguy1000 »

This is easy to do..... though it doesn't seem that way at the start.

First you have to protect the page itself.....  and you have to decide what to do if somebody access a private page even though they aren't logged in.

I'd recommend something like:

{if !isset($customcontent_loggedin)}
  {redirect to='some_other_page'} {* I'll have to dig up or re-invent this little udt *}
{/if}

Then, I'd change the page alias of all of your private pages to have the same prefix, like 'private_blah1', 'private_blah2', etc.

Then the next step if in your page template: I'd use something like this:
{if isset($customcontent_loggedin)}
    {menu}
{else}
  {menu excludeprefix='private_'}
{/if}

such that you're menu when not logged in will not show the pages that have a page alias that starts with 'private_'

Hope this helps.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
davidlanier
New Member
New Member
Posts: 5
Joined: Mon Aug 13, 2007 11:01 pm

Re: What is the best way to show page only to members?

Post by davidlanier »

Thanks for the suggestion, I'll give that a try.

Does this go in page content or in a template? :

{if !isset($customcontent_loggedin)}
  {redirect to='some_other_page'} {* I'll have to dig up or re-invent this little udt *}
{/if}
SimonSchaufi

Re: What is the best way to show page only to members?

Post by SimonSchaufi »

calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: What is the best way to show page only to members?

Post by calguy1000 »

davidlanier wrote: Thanks for the suggestion, I'll give that a try.

Does this go in page content or in a template? :

{if !isset($customcontent_loggedin)}
  {redirect to='some_other_page'} {* I'll have to dig up or re-invent this little udt *}
{/if}
You'll want to put it in the page content....  Or, if you don't want to do that, you could do this:

a) in the metadata field of all of your private pages, add this:
    {assign var='privatepage' value='1'}

b) In your template, add:
    {if !isset($customcontent_loggedin) && isset($privatepage) }
        {redirect to='some_other_page'} {* I'll have to dig up or re-invent this little udt *}
    {/if}

Maybe bbonora or somebody has this little redirection UDT.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “CMSMS Core”