Using a function found in a different file in a loop

Posted by Anders on Stack Overflow See other posts from Stack Overflow or by Anders
Published on 2010-12-28T23:13:34Z Indexed on 2010/12/28 23:54 UTC
Read the original article Hit count: 208

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays