Hey guys,
New to the platform and so far rather impressed with the setup!
Anyway as the title states; I am wondering if its possible to auto assign a new user to a designated group upon registration?
Thanks in Advance
Mitchell
.
<?php
function my_component_init(){
ossn_register_callback('user', 'created', 'my_component_user_created_cb');
}
function my_component_user_created_cb($callback, $type, $variables){
$guid = $variables['guid']; //contains the GUID of newly created user
$group_guid = 1234; //replace with actual group ID
ossn_add_relation($guid, $group_guid, 'group:join');
ossn_add_relation($group_guid, $guid, 'group:join:approve');
}
ossn_register_callback('ossn', 'init', 'my_component_init');
.
Hello Mitchell,
The quick was is if you see : https://github.com/opensource-socialnetwork/opensource-socialnetwork/blob/v5.x/components/OssnGroups/classes/OssnGroup.php#L48-L49
You can see that two add_relation function it actually add the person who creates group into group members.
To add some other user to group when it is created you add following lines below those lines:
ossn_add_relation(otheruserguid, $this->getGuid(), 'group:join');
ossn_add_relation($this->getGuid(), otheruserguid, 'group:join:approve');
Where otheruserguid is integer id of user like 1, 2, 22, 33,
Ok This method is not suggested when official because during next upgrade when you replace files the customization will be gone if you are developer and wanted to take some time you can do following:
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)