aplelois
04-30-2009, 11:25 AM
hello there everyone..
I am trying to have this code here set a forum permission 0 if he/she is younger than 18 but for some reason its not working, can someone tell me why?
<plugin active="1" executionorder="5">
<title>Userage Based Permissions</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[function old_enough($day, $month, $year, $minage){
global $current;
$age = $current['year'] - $year;
// Not underage
if ($age > $minage){
// Do nothing
return true;
}
// Possibly underage
else if ($age == $minage){
// Check the month
if ($month < $current['month']){
// Do nothing
return true;
}
// Possibly underage
else if ($month == $current['month']){
// Check the day
if ($day <= $current['day']){
// Do nothing
return true;
}
// Underage
else {
return false;
}
}
// Underage
else {
return false;
}
}
// Underage
else {
return false;
}
return true;
}
// Make sure they set their birthday
if ($vbulletin->userinfo['birthday']){
// Grab the dates
$date = explode('-', $vbulletin->userinfo['birthday']);
// Get them ready
$day = $date[1];
$month = $date[0];
$year = $date[2];
$current['month'] = date('m');
$current['day'] = date('d');
$current['year'] = date('Y');
}
foreach ($vbulletin->forumcache as $key => $value){
if ($value['minimumage'] > 0 && (!isset($current) || !old_enough($day, $month, $year, $value['minimumage']))){
$vbulletin->userinfo['forumpermissions']["$key"] = 0;
}
}
]]></phpcode>
</plugin>
I am trying to have this code here set a forum permission 0 if he/she is younger than 18 but for some reason its not working, can someone tell me why?
<plugin active="1" executionorder="5">
<title>Userage Based Permissions</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[function old_enough($day, $month, $year, $minage){
global $current;
$age = $current['year'] - $year;
// Not underage
if ($age > $minage){
// Do nothing
return true;
}
// Possibly underage
else if ($age == $minage){
// Check the month
if ($month < $current['month']){
// Do nothing
return true;
}
// Possibly underage
else if ($month == $current['month']){
// Check the day
if ($day <= $current['day']){
// Do nothing
return true;
}
// Underage
else {
return false;
}
}
// Underage
else {
return false;
}
}
// Underage
else {
return false;
}
return true;
}
// Make sure they set their birthday
if ($vbulletin->userinfo['birthday']){
// Grab the dates
$date = explode('-', $vbulletin->userinfo['birthday']);
// Get them ready
$day = $date[1];
$month = $date[0];
$year = $date[2];
$current['month'] = date('m');
$current['day'] = date('d');
$current['year'] = date('Y');
}
foreach ($vbulletin->forumcache as $key => $value){
if ($value['minimumage'] > 0 && (!isset($current) || !old_enough($day, $month, $year, $value['minimumage']))){
$vbulletin->userinfo['forumpermissions']["$key"] = 0;
}
}
]]></phpcode>
</plugin>