phpweb-serviceselgg

Create/edit group web-service in ELGG


I am looking for the webservice which would create the group. I looked at the available web service in elgg . I can only find the following web services related to the group -

Group

Do we have anything for create group web service in elgg.


Solution

  • Please add following function, and its defination in your webservice file in ELGG/engine/lib/web_services.php

    /**
     * The group.save API.
     * This API call lets a user to create group.
     *
     * @param string $name group name
     * @param string $briefdescription short description
     * @param string $description long description
     * @param string $interests tags comma separated
     * @param int $group_guid GUID of group if its edit request
     *
     * @return bool success/fail
     * @access public
     */
    function group_save($name, $briefdescription, $description, $interests, $group_guid)
    { 
       //you can change/pass below parameters from POST
       $_GET['action']='groups/edit';
       $_POST['membership'] = '2';
       $_POST['activity_enable'] = 'yes';
       $_POST['blog_enable'] = 'yes';
       $_POST['forum_enable'] = 'yes';
       $_POST['pages_enable'] = 'yes';
    
       //include file at location "ELGG/mod/groups/actions/groups/edit.php"
       include_once '../../mod/groups/actions/groups/edit.php';
    
       //Or you can copy all code from that file and paste it here. And do modification according to your need.
    
    }
    

    Finally, you should expose a function like following:

    expose_function(
            "group.save",
            "group_save",
            array(
                            'name' => array ('type' => 'string'),
                            'briefdescription' => array ('type' => 'string'),
                            'description' => array ('type' => 'string'),
                            'interests' => array ('type' => 'string'),
                            'group_guid' => array ('type' => 'int', 'required' => false),
            ),
            'User add/edit group',
            'POST',
            true,
            true
        );