Create a new group
//***********************************
//***********************************
//********** ADD NEW GROUP **********
//***********************************
//***********************************
function add_new_group ($AdminUserId, $GroupName, $GroupDescription)
{
//----- CREATE NEW GROUP -----
$args = array();
$args['creator_id'] = $AdminUserId;
$args['name'] = $GroupName;
$args['description'] = $GroupDescription;
$args['status'] = 'hidden';
$group_id = groups_create_group($args);
if (is_wp_error($group_id))
{
//GROUP COULD NOT BE CREATED
return(False);
}
//----- GROUP WAS CREATED -----
//Set group invites allowed by group admin only
$enable_forum = False;
$status = 'hidden';
$invite_status = 'admins';
$parent_id = False;
groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status, $parent_id);
return($group_id);
}
Add member to a group
groups_join_group($GroupId, $UserId);
Remove member from a group
groups_leave_group($GroupId, $UserId);
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.