The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Usergroup Based on Age
Hey all.
I am trying to make a forum only accessible to a certain age group (18+). I figure the easiest way to do this is to make a usergroup as a secondary group for 18+ members. I want to create a simple plugin or scheduled task that will run and automatically add the additional usergroup to people who are 18+. Can anyone give me some advice on where to start? |
#2
|
|||
|
|||
I did this on my site by hacking the promotion system (it required code changes as opposed to plugins). I had to change admincp/usergroup.php to add a promotion strategy, and includes/cron/promotion.php to implement it. If you want I could give you the changes I made, in diff format or something. I did it in vb3, but the code for those files didn't change much for vb4 so it shouldn't be hard to figure out.
|
#3
|
||||
|
||||
Would that method be easier than doing what I proposed? If so I'm definitely open to it.
|
#4
|
|||
|
|||
Well, I guess it's easier because I have it done already, but it requires changing files. It does take advantage of the promotion code that uses a scheduled task to add a secondary group to a user. You could write your own code and use a plugin with one of the cron hooks and then you wouldn't need to modify any files, but you'd have to handle it all yourself.
I'll post my changes and you can use it or do it a different way (even if you don't use these, you might look at promotion.php and see how it works). Anyway, in admincp/usergroup.php, find: Code:
foreach($promotions AS $groupid => $promos) { print_table_header("$vbphrase[promotions]: <span style=\"font-weight:normal\">" . $vbulletin->usergroupcache["$groupid"]['title'] . ' ' . construct_link_code($vbphrase['add_new_promotion'], "usergroup.php?" . $vbulletin->session->vars['sessionurl'] . "do=updatepromotion&usergroupid=$groupid" . ($vbulletin->GPC['returnug'] ? '&returnug=1' : '')) . "</span>", 8); print_cells_row(array( $vbphrase['usergroup'], Then find this and add the section in red, and change the lines in blue: Code:
else if ($promotion['strategy'] == 18) { $type = $vbphrase['join_date']; } else if ($promotion['strategy'] == 32) { $type = 'Age >= 18'; } else { $type = $vbphrase['promotion_strategy' . ($promotion['strategy'] + 1)]; } print_cells_row(array( "<b>$promotion[title]</b>", iif($promotion['type']==1, $vbphrase['primary_usergroup'], $vbphrase['additional_usergroups']), $type, iif($promotion['strategy'] != 32, $promotion['reputation'], 'N/A'), iif($promotion['strategy'] != 32, $promotion['date'], 'N/A'), iif($promotion['strategy'] != 32, $promotion['posts'], 'N/A'), construct_link_code($vbphrase['edit'], "usergroup.php?" . $vbulletin->session->vars['sessionurl'] . "userpromotionid=$promotion[userpromotionid]&do=updatepromotion" . ($vbulletin->GPC['returnug'] ? '&returnug=1' : '')) . construct_link_code($vbphrase['delete'], "usergroup.php?" . $vbulletin->session->vars['sessionurl'] . "userpromotionid=$promotion[userpromotionid]&do=removepromotion" . ($vbulletin->GPC['returnug'] ? '&returnug=1' : '')), )); Code:
$promotionarray = array( 32=> 'Age >= 18', 17=> $vbphrase['posts'], 18=> $vbphrase['join_date'], 16=> $vbphrase['reputation'], |
Благодарность от: | ||
AzzazelCyC |
#5
|
|||
|
|||
In includes/cron/promotion.php, find this and add the line in red:
Code:
SELECT user.joindate, user.userid, user.membergroupids, user.posts, user.reputation, user.usergroupid, user.displaygroupid, user.customtitle, user.username, user.ipoints, YEAR(user.birthday_search) AS birth_year, MONTH(user.birthday_search) AS birth_month, DAY(user.birthday_search) AS birth_day, userpromotion.joinusergroupid, userpromotion.reputation AS jumpreputation, userpromotion.posts AS jumpposts, userpromotion.date AS jumpdate, userpromotion.type, userpromotion.strategy, usergroup.title, usergroup.usertitle AS ug_usertitle, usertextfield.rank More lines to add: Code:
$secondarynames = array(); $titles = array(); $today = getdate(TIMENOW); $min_age = 18; while ($promotion = $vbulletin->db->fetch_array($promotions)) { And another: Code:
$posts = false; $joindate = false; $age = false; // These strategies are negative reputation checking if (($promotion['strategy'] > 7 AND $promotion['strategy'] < 16) OR $promotion['strategy'] == 24) And another: Code:
if ($daysregged >= $promotion['jumpdate']) { $joindate = true; } if ($promotion['birth_year'] > 1900 AND $promotion['birth_month'] >= 1 AND $promotion['birth_month'] <= 12 AND $promotion['birth_day'] >= 1 AND $promotion['birth_day'] <= 31) { $yeardiff = $today['year'] - $promotion['birth_year']; if ($yeardiff > $min_age OR ($yeardiff == $min_age AND ($today['mon'] > $promotion['birth_month'] OR ($today['mon'] == $promotion['birth_month'] AND $today['mday'] >= $promotion['birth_day'])))) { $age = true; } } if ($promotion['strategy'] == 17) { $dojoin = iif($posts, true, false); } Last one: Code:
else if ($promotion['strategy'] == 16 OR $promotion['strategy'] == 24) { $dojoin = iif($reputation, true, false); } else if ($promotion['strategy'] == 32) { $dojoin = iif($age, true, false); } else { switch($promotion['strategy']) Then of course you need to go to the Promotions manager and add a promotion using the new "Age >= 18" strategy. The way promotions work is when the scheduled task runs it will promote everyone who's eligible and who has been active recently. If you want to immediately promote everyone who's eligible, you can run the scheduled task manually from the Scheduled Task manager. |
Благодарность от: | ||
tbworld |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|