# fluent-community/2.6.0/app/Hooks/CLI/Commands.php

FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS &amp; Online Courses, version 2.6.0. 205 lines.

- Page: https://pluginprobe.com/plugins/fluent-community/2.6.0/code/app/Hooks/CLI/Commands.php
- Raw: https://pluginprobe.com/plugins/fluent-community/2.6.0/raw/app/Hooks/CLI/Commands.php
- Modified: 2026-04-30T14:25:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-community/2.6.0/code/app/Hooks/CLI/Commands.php#L10-L20`.

```php
<?php

namespace FluentCommunity\App\Hooks\CLI;

use FluentCommunity\App\Models\XProfile;
use FluentCommunity\Modules\Migrations\Helpers\BPMigratorHelper;
use FluentCommunity\Modules\Migrations\Helpers\PostMigrator;
use FluentCommunity\App\Models\User;
use FluentCommunity\Framework\Support\Arr;

class Commands
{

    public function migrate_from_bb($args, $assoc_args = [])
    {
        $migrator = new BuddyPressMigrator();

//        $migrator->migrateGroups();
//
//        die();


//        $migrator->migratePosts();
//
//        die('Yap');
//
//

//        $postMigrator = new PostMigrator(13461);
//        $feed = $postMigrator->migrate();
//        dd($feed);


//        \WP_CLI::line('Starting BuddyPress Data Migration...');
//        BPMigratorHelper::deleteCurrentData();
//        \WP_CLI::line('Deleted existing Fluent Community data.');
//        $migrator->migrateGroups();
//
//        die();

        \WP_CLI::line('Starting BuddyPress Data Migration...');
        BPMigratorHelper::deleteCurrentData();
        \WP_CLI::line('Deleted existing Fluent Community data.');
        $migrator->migrateGroups();
        \WP_CLI::line('Migrated BuddyPress Groups to Fluent Community Spaces.');
        $migrator->syncGroupMembers();
        \WP_CLI::line('Synchronized Group Members to Space Members.');
        $migrator->migratePosts();
        \WP_CLI::line('Migrated BuddyPress Posts to Fluent Community Feeds.');
        $migrator->syncUsers();
        \WP_CLI::line('Synchronized Users.');

        \WP_CLI::line('Calculating User points.');
        $this->recalculate_user_points();

        \WP_CLI::success('BuddyPress Data Migration Completed Successfully.');

        die();

//
//        die();

//        $migrator->migratePosts();
//        die();

        $postMigrator = new PostMigrator(13052);

        $feed = $postMigrator->migrate();

        dd($feed);

        die();


//        $stats = $migrator->getStats();
//        \WP_CLI::line('BuddyPress Data Stats:');
//        \WP_CLI\Utils\format_items('table', $stats, ['key', 'count']);

        BPMigratorHelper::deleteCurrentData();
        $migrator->migratePosts();

        die('OK');

        $migrator->migrateGroups();
        $migrator->syncGroupMembers();
        $migrator->migratePosts();
        $migrator->syncUsers();

        $fluentStats = [
            [
                'key'   => 'Total Users',
                'count' => XProfile::count()
            ],
            [
                'key'   => 'Total Spaces',
                'count' => \FluentCommunity\App\Models\Space::count()
            ],
            [
                'key'   => 'Total Posts',
                'count' => \FluentCommunity\App\Models\Feed::count()
            ],
            [
                'key'   => 'Total Comments',
                'count' => \FluentCommunity\App\Models\Comment::count()
            ],
            [
                'key'   => 'Total Reactions',
                'count' => \FluentCommunity\App\Models\Reaction::count()
            ]
        ];

        \WP_CLI\Utils\format_items('table', $fluentStats, ['key', 'count']);

    }

    /**
     * usage: wp fluent_community sync_x_profile --force
     */
    public function sync_x_profile($args, $assoc_args = [])
    {
        $isForced = Arr::get($assoc_args, 'force', false) == 1;

        $users = User::orderBy('ID', 'ASC')->get();

        foreach ($users as $user) {
            $result = $user->syncXProfile($isForced);
            \WP_CLI::line('Synced XProfile for UserID: ' . $user->ID . ' - ' . $result->id);
        }

        \WP_CLI::success('XProfile Synced Successfully');
    }

    /**
     * usage: wp fluent_community recalculate_user_points
     */
    public function recalculate_user_points()
    {
        $xProfiles = \FluentCommunity\App\Models\XProfile::all();

        $progress = \WP_CLI\Utils\make_progress_bar('Recalculating Points', count($xProfiles));

        foreach ($xProfiles as $xProfile) {

            $progress->tick();

            $currentPoint = BPMigratorHelper::recalculateUserPoints($xProfile->user_id);
            if ($currentPoint > $xProfile->total_points) {
                $oldPoints = $xProfile->total_points;
                $xProfile->total_points = $currentPoint;
                $xProfile->save();
                do_action('fluent_community/user_points_updated', $xProfile, $oldPoints);
                \WP_CLI::line(
                    'Recalculated Points for User: ' . $xProfile->display_name . ' - ' . $oldPoints . ' to ' . $currentPoint
                );
            }
        }

        $progress->finish();

        \WP_CLI::success('Points Recalculated Successfully for ' . count($xProfiles) . ' users');
    }


    public function download()
    {
        $baseUrl = 'https://community.buddyboss.com/wp-json/wp/v2/users/?per_page=50&page=';

        $page = 590;

        while (true) {
            $response = wp_remote_get($baseUrl . $page, [
                'timeout' => 60,
            ]);

            if (is_wp_error($response)) {
                \WP_CLI::error('Error fetching page ' . $page . ': ' . $response->get_error_message());
                continue;
            }

            $json = wp_remote_retrieve_body($response);
            $users = json_decode($json, true);
            if (empty($users)) {
                \WP_CLI::line('No more users found on page ' . $page );
                break; // No more users to fetch, exit the loop
            }

            // save the json to a file
            file_put_contents(ABSPATH . '/dump/' . $page . '.json', $json);

            \WP_CLI::line('Downloaded page ' . $page);


            $page++;
        }

        \WP_CLI::success('Download Completed');


    }




}

```
