0

This question is related to BuddyPress, and a follow-up question from this question

I have a .csv-file with 790 rows and 3 columns where the first column is the group name, second is the group description and last (third) the slug.

As far as I've been told I can use this code:

<?php

$groups = array();

if (($handle = fopen("groupData.csv",
"r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $group = array('group_id'    =>    'SOME ID', 
                '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'   );
        $groups[] = $group;
    }   
    fclose($handle); }

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

With http://www.nomorepasting.com/getpaste.php?pasteid=35217 which is called bp-groups.php.

The thing is that I can't make it work. I've created a new file with the code written above called groupgenerator.php uploaded the .csv file to the same folder and opened groupgenerator.php in my browser. But, i get this error: Fatal error: Call to undefined function groups_check_slug() in

What am I doing wrong?

Community
  • 1
  • 1
Anders
  • 633
  • 2
  • 11
  • 21
  • 3
    are you using an include 'file.php'; to include the file that contains the function groups_check_slug()? – CrowderSoup Dec 28 '10 at 23:21
  • No, I have not. I have only used the code which is written here on stackoverflow. – Anders Dec 28 '10 at 23:22
  • I tried it now and got this in return: **Parse error: syntax error, unexpected T_VARIABLE in /hidden/groupgenerator.php on line 5** line 5: $groups = array(); – Anders Dec 28 '10 at 23:26

1 Answers1

0

I solved the error message by including wp-load.php in the code. But it doesn't solve my main problem. I'll post a new question with my problem.

Anders
  • 633
  • 2
  • 11
  • 21