Any BuddyPress/BuddyBoss pros who can help me from going insanse?

[ad_1]

I have been driving my self nucking futs trying to figure out how to assign a parent\_id to a group in BuddyBoss.

​

**Context**
I have \~500 groups in BuddyBoss. I exported the meta for each and assigned a parent\_id to groups that I want to be sub groups of other groups. However, I can’t for the life of me figure out how to import the .csv to update the parent\_id for those groups without getting a syntax error related to how the data is formatted.

​

**Code (thus far)**

function update_buddyboss_group_parents($test_mode = false) {
$csv_url = /*CSV*/;
$csv_path = download_url($csv_url);

if (is_wp_error($csv_path)) {
error_log(‘Error downloading CSV file: ‘ . $csv_path->get_error_message());
return;
}

$handle = fopen($csv_path, “r”);

if ($handle !== FALSE) {
while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE) {
$group_id = intval($data[0]);
$parent_id = intval($data[5]);
$creator_id = intval($data[7]);
$name = $data[1];
$slug = $data[2];
$description = $data[3];
$status = $data[4];
$enable_forum = intval($data[6]);

if ($test_mode) {
// Log the intended update in test mode
error_log(“Test Mode: Would update group ID $group_id with parent ID $parent_id and other details”);
} else {

$result = groups_edit_group_settings($group_id, $parent_id, $creator_id, $name, $slug, $description, $status, $enable_forum);

if (!$result) {
error_log(“Failed to update group settings for group ID $group_id”);
}
}
}
fclose($handle);
} else {
error_log(‘Unable to open CSV file.’);
}

unlink($csv_path);
}

// test call
update_buddyboss_group_parents(false);

I would appreciate any, some, all, or whatever the heck kind of help I can get here.

[ad_2]
2 Comments
  1. Give me an example first. I need to visualize it
    So say you have groups

    cats
    Dogs
    Horses
    Rats
    Snakes

    Now, you want other groups to become sub groups of the groups such as cats dogs horses rats and snakes ?
    Where you assign the sub group to a parent group ?
    Is that what you are trying to do ??

    Also do you think maybe MariaDB can be the issue here ? Instead of using MYSQL ?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer