1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
include "../../../wp-load.php";

$groups = array();

if (($handle = fopen("groupData.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $group = array('group_id'    => 'SOME ID',
                'creator_id'  => '1',
                'name'        => $data[0], 
                'description' => $data[1], 
                'slug' => groups_check_slug(sanitize_title(esc_attr($data[2]))), 
                'date_created' => gmdate( "Y-m-d H:i:s" ), 
                'status' => 'public', 
                'enable_forum' => '1'
 );
        $groups[] = $group;
    }   
    fclose($handle);
}

foreach ($groups as $group) {
    groups_create_group($group);
} 

?>