18+ Age Requirement

Submitted by Anonymous on Fri, 03/13/2009 - 03:25
Written by
djicon09

Hello, I just installed UseBB. So far I'm extremely happy with it. I would like to make my board so only people 18+ can get on it. Does anyone know how to do that?

Thanks

this is basic if they put they are 13 they can just go back and put they are 18! you can modifie it so it makes a session then do it so if that session exists it wont let you register till the session is destroyed.

you could add somat like this to the register form


Age: <input name="age" type="text" id="age" size="2" maxlength="2">

then add this to the register page


if ( $_POST['age'] >= 18) {`
register form here
}
else {
print "You are not old enough you need to be 18!";
}

NOT TESTED!!!

print does not work inside UseBB procedural code. :) You need to use the template system.

Moving to customization forum.

oh ok :S what is the template system for print then?

$template->add_raw_content('Content here');

That is indeed a posible way of adding contents, however the most dirty one. :)

In fact you should alter the code to add a nice message box when needed instead of printing raw messages.

Yeah, was the only thing I could remember off the top of my head XD.


$template->parse('msgbox', 'global', array(
'box_title' => 'your title',
'content' => 'your content',
));

:P

fair enuf :D


if ( $_POST['age'] >= 18) {
register form here
}
else {
$template->parse('msgbox', 'global', array(
'box_title' => 'Your Under Age',
'content' => 'Sorry you need to be 18 to veiw this site',
));
}

that ok? :D

Now also use the language variables found in $lang. :)

Haha, I had a feeling you'd say that :P. I was going to initially add them in, but laziness took over. :)

Viola:


if ( $_POST['age'] >= 18) {
register form here
}
else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['YourTitle'],
'content' => $lang['YourContent'],
));
}

wow, this topic has really taken off, lol. Will the last post by Gaia work?

You need to fit the code in the proper place, you can't just wrap the if/else around all the code in panel_register.php.

Best is if anyone makes a mod for this that has been tested and can be applied when needed.

ill do it when i get home atm im at work

what about this
if you put your age as 0-17 it will add your ip to a database, then if you go to register to that site ever again it wont let you register. Theres probly a error i had to rush it as my break ended 5 mins ago :lol:


$agerequirement = $db->query("SELECT ip FROM ".TABLE_PREFIX."age_reqirement WHERE ip = '".$session->sess_info['ip_addr']."'");
if ($agerequirement == ""){
if ( $_POST['age'] >= 18) {
/* Register form here */
}
else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Your Underage'],
'content' => $lang['You need to be 18 to veiw the content within this forum.'],
$db->query("INSERT INTO ".TABLE_PREFIX."age_reqirement (ip) VALUES ('".$session->sess_info['ip_addr']."'");
));
}

}
else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Your Underage'],
'content' => $lang['You need to be 18 to veiw the content within this forum.'],
}

That wouldn't work.......there are quite a few things that are incorrect....just to name a few:

1. You wouldn't need a new database table, or entry for that matter.
2. $lang cannot be used in that manner.
3. You'd have to edit the register form HTML in the correct .tpl.php template file

If you were coding your own standalone form, then yes, something like that may theoretically work. But that code isn't something you can just "slap around" the current UseBB code.