Topic: Under 18
wicked

Noob
Noob
Posts: 11

Posted:
Jul 26, 2005

I've added a new field in the users table: $birthday

Code
  1. `pn_birthday` varchar(25) NOT NULL default ''
  2.  


$birthday = pnUserGetVar('birthday');
$now = date();
$years_old = $now - $birthday;
$years_old = date("y", $years_old);

I try to don't show the news under the topic "sex" ($tid == "2") to the users that their age < 18 and show an error message if they try to see it, but i don't know what i have to do... LOST...

Any idea?? :( :( :(

Sorry for my english :!:
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
Jul 26, 2005

mmm...

Could take a little more than that.

Best way possible is to add the kiddos into a group (you must know there are under 18), then simply add a permission for them not to see the specific topic.


Chestnut ! Cool
Site Admin
wicked

Noob
Noob
Posts: 11

Posted:
Jul 26, 2005

umMMMm, it's a great idea, very simple and nice :)

But works with dates is a beat complicated for me :( I would do a sql for insert those users wich $now - $birthday (date in years) will be < 18 and delete them when this sustraction be > 18 :(

I repeat: sorry for my bad english :(
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
Jul 27, 2005

First, I'm not sure you pn_birthday field can work that way...

You should create a dynamic field instead as to not break the DB for future updates.

Secondlyn unless you are filling the birthday field yourself, from what I can see, you are assuming that they are filling their birthday in a timestamp format wich I doubt anyone can....... unless some autist able to count the number of seconds since 1970..... :wink:

One of way that could work is to make 3 dyna fields
_BIRTHDAY
_BIRTHMONTH
_BIRTHYEAR

That way, it'll be a breeze to combine them using the mktime function ( http://www.php.net/mktime )

Then, you'll be able to do easily a $now - mktime(0,0,0, $month, $day, $year) to know if he has more or less than 18.

Something like that.


Chestnut ! Cool
Site Admin
wicked

Noob
Noob
Posts: 11

Posted:
Jul 27, 2005

I understand... but... my big problem is the same...

Thanks for all Chestnut, keep up the good work!
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
Jul 27, 2005

mmm The future uses of hooks within PostNuke will make our lives so much simpler, you can't imagine.

I know what I mean... icon_lol

:wink:


Chestnut ! Cool
Site Admin
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
Jul 27, 2005

wickedI understand... but... my big problem is the same...


Wich is ? If building the thing it is, then I admit that I don't have any automated way I'm afraid and building it might need a little reflexion...

The sql and all...

Not necessarily hard... but still...

1 Getting all your users
2 Building the birthtime from their info

3 Moving through your result and if > 18, removing from non-priviledged group else... adding them...

But it quite manual.


Chestnut ! Cool
Site Admin