PDA

View Full Version : Userage Based Permissions


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>

Dismounted
04-30-2009, 12:07 PM
aplelois,

You are currently showing up as unlicensed.

To be able to download modifications and/or receive support here at vBulletin.org, we ask you to please click here (http://members.vbulletin.com/membersupport_priority.php) (vB-Germany users click here (http://members.vbulletin-germany.com/membersupport_priority.php), vB-Chinese users click here (http://members.vbulletin-china.cn/membersupport_priority.php)) and enter your email address. You will need to use your customer number and password (which will be in the email you got when you paid for your license) to access that page. Please note that your email is case sensitive.

To protect our customers privacy you will also need to Opt-In to license validation for all Support Sites. You must authorise vBulletin.org in order to validate your license status here. You can do this at the page linked above for your distributor. Make sure to set the permission to allow vBulletin.org to validate your status.

The update of your account can take up to one hour.

Thank you.