Auto-creating groups broke with Elgg 2.3

Hi all.

In Elgg 2.2 I had the following hook to auto-create group(s) after user validated by e-mail:

elgg_register_event_handler( 'validate:after', 'user', 'validate_event_handler', 9999 );

function validate_event_handler( $event, $object_type, $user ) {
    if( $user ) {
        elgg_set_ignore_access( true );
        access_show_hidden_entities( true );
        $data1 = $user->data1;
        $data2 = $user->data2;
        $groupname = $data1.' '.$data2;
        $groupList = elgg_get_entities_from_attributes( array( 'type' => 'group', 'subtype' => 'subtype', 'attribute_name_value_pairs' => array( array( 'name' => 'name', 'operand' => '=', 'value' => $groupname, 'case_sensitive' => false ) ) ) );
        if( is_array( $groupList ) ) $group = $groupList[0];
        if( !elgg_instanceof( $group, 'group' ) ) {
            $gdesc = 'Description';
            $group_owner_guid = 293; //Owner of all auto-created groups with administrator privilege
            $group = new ElggGroup();
            $group->subtype = 'subtype';
            $group->name = $groupname;
            $group->description = $gdesc;
            $group->membership = ACCESS_PRIVATE;
            $group->setContentAccessMode(ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY);
            $group->owner_guid = $group_owner_guid;
            $group->save();
            $group->access_id = $group->group_acl;
            $group->save();
        }
        $group->join( $user );
        access_show_hidden_entities( false );
        elgg_set_ignore_access( false );
        return true;
    }
    return false;
}

However, after upgrade to Elgg 2.3 this doesn't work any more. Help would be very much appreciated.

BR,
ZP

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking