<?php
/**
 * Debug script to check user status fields
 */

// Include WordPress
require_once('/Users/ben/dev/upskill-event-manager/../../../../../../Applications/Local/lightning-services/php-8.0.30+7/bin/darwin/bin/php');

// Check what user meta fields exist
$users = get_users(['number' => 10]);

echo "=== USER STATUS DEBUG ===\n\n";

foreach ($users as $user) {
    echo "User ID: {$user->ID}\n";
    echo "Email: {$user->user_email}\n";
    
    // Check all meta fields
    $meta = get_user_meta($user->ID);
    foreach ($meta as $key => $value) {
        if (strpos($key, 'status') !== false || strpos($key, 'approval') !== false) {
            echo "  {$key}: " . print_r($value, true) . "\n";
        }
    }
    
    // Check roles
    echo "  Roles: " . implode(', ', $user->roles) . "\n";
    echo "\n";
}

// Check trainer profiles
echo "=== TRAINER PROFILES ===\n\n";

$profiles = get_posts([
    'post_type' => 'trainer_profile',
    'posts_per_page' => 5,
    'post_status' => 'publish'
]);

foreach ($profiles as $profile) {
    echo "Profile ID: {$profile->ID}\n";
    echo "Title: {$profile->post_title}\n";
    
    $user_id = get_post_meta($profile->ID, 'user_id', true);
    $is_public = get_post_meta($profile->ID, 'is_public_profile', true);
    
    echo "  User ID: {$user_id}\n";
    echo "  Is Public: {$is_public}\n";
    
    if ($user_id) {
        $user = get_user_by('ID', $user_id);
        if ($user) {
            echo "  User Email: {$user->user_email}\n";
            echo "  User Roles: " . implode(', ', $user->roles) . "\n";
        }
    }
    echo "\n";
}
?>