I have a system in which users can register with my forum via the website using PHP. I now need the ability to assign them to groups when this happens… or in some cases create a new group and assign them to it.
I’ve had a look around the phpBB files but cannot figure out which parts of the scripts are responsible for this work.
Basically I need the following operations:
- Ability to dynamically create a group
- Ability to add user to a group
- Ability to set group permissions for a forum
This all has to be dynamic as the system needs to be automated and not managed via the ACP.
If anyone could point me in the right direction for these that would be great.
Solved – 13/03/2012
Here’s the solution I came up with utlising group_create() from includes/functions_user.php.
$group_id = FALSE; // can be 0 as well
$group_type = GROUP_HIDDEN;
$group_name = "Tom's Group";
$group_desc = "Users from Tom's Group";
// just leave these as defaults
$group_attributes = array(
//'group_colour' => 0,
//'group_rank' => 0,
//'group_avatar' => 0,
//'group_avatar_type' => 0,
//'group_avatar_width' => 0,
//'group_avatar_height' => 0,
'group_legend' => 0,
);
$allow_desc_bbcode = TRUE;
$allow_desc_urls = TRUE;
$allow_desc_smilies = TRUE;
$response = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
Note that if you set $group_id as an existing group in your database then it will modify that group.
I also set group_legend as 0 because I don’t want hidden groups to be seen on the forum.
There’s a section called area51.phpbb.
There are bugs tracker, discussions and documents about phpBB development.
Here’s something I’ve found that is related to adding/editing groups.
http://area51.phpbb.com/docs/code/30x/phpbb3/package-functions.html#group_create()
According to it , the function
group_createis in:Check out also the next links:
http://wiki.phpbb.com/Main_Page
http://area51.phpbb.com/phpBB/