Forums / Setup & design / Displaying specific folders to users of a minimum age

Displaying specific folders to users of a minimum age

Author Message

Andy Woods

Monday 04 April 2011 10:54:56 am

I'm developing a site for children aged between 5 and 18.

Some folders are only to be viewed by young people that are at secondary school (aged 12+).

I've added a date field in the 'User' class to specify each user's date of birth.

Can anyone help me with the code I need to be able to:

a) determine how old a user is

b) how I would enable children of age 12+ to see specific folders but not display them to children younger than 12 years old

Thanks,

Andy

Gaetano Giunta

Tuesday 05 April 2011 1:06:37 am

Not a detailed walkthrough, but here you go:

1. take care about the datatype used for 'date of birth'. Standard date datatype cannot go below 1/1/1970, so if your website has also older people registered, you need a custom datatype (there is an extension or two on projects.ez.no with that)

2. you should create two roles, and divide users in two groups, each with one role assigned. Then move boys in group A, with role 'boys', and kids to group B, with role 'kids'. Assign read different read permissions to kids and boys groups.

3. Use the workflow system to make sure that when accounts are created, the user is put in the proper group depending on his age (unless you do this manually)

4. Set up a cronjob that runs once a day and checks if kids have become old enough to be migrated to boys

Principal Consultant International Business
Member of the Community Project Board

Andy Woods

Tuesday 05 April 2011 11:54:21 am

Thanks Gaetano,

That looks like a good plan.

Can you tell me the table and field I need to update to change the user's group please?

Thanks,

Andy

Gaetano Giunta

Wednesday 06 April 2011 1:52:03 am

To change a group that a user is in I recommend you do not try to access the db directly, but use the eZP php api dealing with content objects. The operation you want to do is move a node.

Principal Consultant International Business
Member of the Community Project Board