| Topic: | Under 18 |
|---|---|
|
wicked
Noob
Posts: 11 Posted: |
I've added a new field in the users table: $birthday $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
Site Admin Posts: 1320 Posted: |
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 ! ![]() Site Admin |
|
wicked
Noob
Posts: 11 Posted: |
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
Site Admin Posts: 1320 Posted: |
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 ! ![]() Site Admin |
|
wicked
Noob
Posts: 11 Posted: |
I understand... but... my big problem is the same... Thanks for all Chestnut, keep up the good work! |
|
Chestnut
Site Admin Posts: 1320 Posted: |
mmm The future uses of hooks within PostNuke will make our lives so much simpler, you can't imagine. I know what I mean... :wink: Chestnut ! ![]() Site Admin |
|
Chestnut
Site Admin Posts: 1320 Posted: |
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 ! ![]() Site Admin |