Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
Create Private Group Forums (automatically)
xxclixxx
Join Date: Mar 2008
Posts: 8

 

Show Printable Version Email this Page Subscription
xxclixxx xxclixxx is offline 03-12-2008, 10:00 PM

I'm in the process of integrating vBulletin into my existing site. Part of that, is I have Teams that have their own private forums. I found the Add new Users article very helpful, so I figured why not share what I figured out too.

Basically what this does is creates a new usergroup, creates a new child forum, and restricts access to the child forum to registered users, and gives access to the new usergroup.

You will need to edit the parentid in the code to the ID of your forum these will be children of. You don't need to do any special permissions to that main forum either, as the permissions are set to the sub children.

You'll notice three sets of forumpermissions. Only edit the one that's below the comment saying to edit that one, if necessary. The others are purposely set to 0 to give the private forums privacy =P

PHP Code:
$teamarray = array (
 
'title' => "Team Title",
 
'description' => "Team Description",
 
'usertitle' => "Team User Title",
 
'opentag' => '',
 
'closetag' => '',
 
'passwordexpires' => '',
 
'passwordhistory' => '',
 
'ispublicgroup' => '0',
 
'canoverride' => '1',
 
'forumpermissions' => 0,
 
'genericpermissions' => 0,
 
'attachlimit' => '1000000',
 
'pmquota' => '0',
 
'pmpermissions' => 0,
 
'pmsendmax' => '5',
 
'calendarpermissions' => 0,
 
'wolpermissions' => 1,
 
'adminpermissions' => 0,
 
'genericoptions' => 41,
 
'profilepicmaxwidth' => '100',
 
'profilepicmaxheight' => '100',
 
'profilepicmaxsize' => '25000',
 
'avatarmaxwidth' => '50',
 
'avatarmaxheight' => '50',
 
'avatarmaxsize' => '20000',
 
'signaturepermissions' => 0,
 
'sigpicmaxwidth' => '',
 
'sigpicmaxheight' => '',
 
'sigpicmaxsize' => '',
 
'sigmaxrawchars' => '',
 
'sigmaxchars' => '',
 
'sigmaxlines' => '',
 
'sigmaxsizebbcode' => '7',
 
'sigmaximages' => '',
);

$db->query_write(fetch_query_sql($teamarray'usergroup'));
$usergroupid $db->insert_id();

$forumdata =& datamanager_init('Forum'$vbulletinERRTYPE_CP);
$forumdata->set('title''Team Name Private Forum');
$forumdata->set('description''The private forum for Team ');
$forumdata->set('link''');
$forumdata->set('displayorder'1);
$forumdata->set('parentid'18);
$forumdata->set('daysprune', -1);
$forumdata->set('defaultsortfield''lastpost');
$forumdata->set('defaultsortorder''desc');
$forumdata->set('showprivate'0);
$forumdata->set('newpostemail''');
$forumdata->set('newthreademail''');
$forumdata->set_bitfield('options''moderatenewpost'0);
$forumdata->set_bitfield('options''moderatenewthread'0);
$forumdata->set_bitfield('options''moderateattach'0);
$forumdata->set_bitfield('options''styleoverride'0);
$forumdata->set_bitfield('options''canhavepassword'1);
$forumdata->set_bitfield('options''cancontainthreads'1);
$forumdata->set_bitfield('options''active'1);
$forumdata->set_bitfield('options''allowposting'1);
$forumdata->set_bitfield('options''indexposts'1);
$forumdata->set_bitfield('options''allowhtml'0);
$forumdata->set_bitfield('options''allowbbcode'1);
$forumdata->set_bitfield('options''allowimages'1);
$forumdata->set_bitfield('options''allowsmilies'1);
$forumdata->set_bitfield('options''allowicons'1);
$forumdata->set_bitfield('options''allowratings'1);
$forumdata->set_bitfield('options''countposts'1);
$forumdata->set_bitfield('options''showonforumjump'1);
$forumdata->set(styleid, -1);
$forumdata->set(password'');

$forumid $forumdata->save();

// Edit the below forumpermissions
$querydata = array(
    
'usergroupid' => $usergroupid,
    
'forumpermissions' => 1048575,
    
'forumid' => $forumid
);
        
$query fetch_query_sql($querydata'forumpermission');
$db->query_write($query);

$querydata = array(
    
'usergroupid' => 2,
    
'forumpermissions' => 0,
    
'forumid' => $forumid
);
        
$query fetch_query_sql($querydata'forumpermission');
$db->query_write($query);        
        
build_forum_permissions(); 
There you go, it should be enough to get you started quicker than it took me. Oh and before you ask, the only included files I am using are these, however I'm also doing other functions as well so I don't really know which ones are required but you can just remove each file one by one until it flips out and wants the file back =P

PHP Code:
define('THIS_SCRIPT'__FILE__);
define('FORUMPATH''/home/startx/public_html/forums');
$cwd getcwd();
chdir(FORUMPATH);
require_once(
'./includes/init.php'); // includes class_core.php
require_once('./includes/class_dm.php'); // for class_dm_user.php
require_once('./includes/class_dm_user.php'); // for user functions
require_once('./includes/functions.php'); // vbsetcookie etc.
require_once('./includes/functions_login.php'); // process login/logout 
Reply With Quote
  #2  
Old 07-12-2008, 02:49 PM
ringleader's Avatar
ringleader ringleader is offline
 
Join Date: Dec 2006
Location: Dublin, Ireland
Posts: 192
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Absolutely smashing stuff - worked first time

Thank you for sharing this!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05053 seconds
  • Memory Usage 2,236KB
  • Queries Executed 15 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (1)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete