开发者

Using a function found in a different file in a loop

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;
    }   
    fc开发者_开发问答lose($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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜