# HVAC Administrator Setup Guide

**Version**: 2.0.0  
**Last Updated**: August 28, 2025  
**Audience**: WordPress Administrators, DevOps Engineers  
**Plugin**: HVAC Community Events

## Executive Summary

This comprehensive guide covers the installation, configuration, and maintenance of the HVAC Community Events WordPress plugin. It provides step-by-step instructions for initial setup, integration with third-party services, user management, and ongoing maintenance procedures.

## Table of Contents

1. [System Requirements](#system-requirements)
2. [Pre-Installation Checklist](#pre-installation-checklist)
3. [Installation Process](#installation-process)
4. [Initial Configuration](#initial-configuration)
5. [User Role Setup](#user-role-setup)
6. [The Events Calendar Integration](#the-events-calendar-integration)
7. [Venue and Organizer Setup](#venue-and-organizer-setup)
8. [Email Configuration](#email-configuration)
9. [Security Configuration](#security-configuration)
10. [Performance Optimization](#performance-optimization)
11. [Backup and Recovery](#backup-and-recovery)
12. [Troubleshooting](#troubleshooting)
13. [Maintenance Procedures](#maintenance-procedures)
14. [Migration Guide](#migration-guide)
15. [API Configuration](#api-configuration)

## System Requirements

### Minimum Requirements

```yaml
WordPress:
  version: "6.0+"
  multisite: false
  
PHP:
  version: "8.0+"
  extensions:
    - mysqli
    - curl
    - json
    - mbstring
    - zip
    - gd or imagick
    - opcache (recommended)
  
MySQL:
  version: "5.7+"
  or: "MariaDB 10.3+"
  
Server:
  memory_limit: "256M"
  max_execution_time: "300"
  upload_max_filesize: "50M"
  post_max_size: "50M"
  
SSL:
  required: true
  protocol: "TLS 1.2+"
```

### Recommended Configuration

```yaml
PHP:
  version: "8.2"
  memory_limit: "512M"
  max_input_vars: "3000"
  
MySQL:
  version: "8.0"
  innodb_buffer_pool_size: "256M"
  
Cache:
  type: "Redis or Memcached"
  memory: "128M"
  
CDN:
  recommended: true
  for: "static assets"
```

### Required WordPress Plugins

1. **The Events Calendar** (Free or Pro)
   - Version: 5.0+
   - Purpose: Event management foundation

2. **The Events Calendar Community Events** (Optional)
   - Version: Compatible with TEC
   - Purpose: Frontend event submission

### Recommended Plugins

1. **WP Mail SMTP** - Reliable email delivery
2. **UpdraftPlus** - Backup solution
3. **Wordfence** - Security enhancement
4. **WP Rocket** - Performance optimization
5. **Redirection** - URL management

## Pre-Installation Checklist

### Server Preparation

- [ ] Verify PHP version and extensions
- [ ] Check MySQL version and permissions
- [ ] Confirm SSL certificate installation
- [ ] Set up staging environment
- [ ] Configure automated backups
- [ ] Install WP-CLI (recommended)
- [ ] Set up error logging
- [ ] Configure file permissions

### WordPress Preparation

- [ ] Fresh WordPress installation or backup existing
- [ ] Install and activate The Events Calendar
- [ ] Configure permalink structure (/%postname%/)
- [ ] Set timezone to local timezone
- [ ] Create backup of database
- [ ] Disable caching plugins temporarily
- [ ] Enable debug mode for installation

### File Permissions

```bash
# WordPress root directory
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

# Specific directories
chmod 755 wp-content
chmod 755 wp-content/plugins
chmod 755 wp-content/themes
chmod 755 wp-content/uploads

# Plugin directory (after installation)
chmod -R 755 wp-content/plugins/hvac-community-events
chmod -R 644 wp-content/plugins/hvac-community-events/*.php
```

## Installation Process

### Method 1: Manual Installation

1. **Download Plugin Package**
   ```bash
   # From repository
   git clone https://github.com/your-repo/hvac-community-events.git
   
   # Or download ZIP and extract
   unzip hvac-community-events.zip
   ```

2. **Upload to WordPress**
   ```bash
   # Copy to plugins directory
   cp -r hvac-community-events /path/to/wordpress/wp-content/plugins/
   
   # Set permissions
   chown -R www-data:www-data /path/to/wordpress/wp-content/plugins/hvac-community-events
   chmod -R 755 /path/to/wordpress/wp-content/plugins/hvac-community-events
   ```

3. **Activate Plugin**
   ```bash
   # Via WP-CLI
   wp plugin activate hvac-community-events
   
   # Or through WordPress Admin
   # Navigate to Plugins → Installed Plugins → Activate
   ```

### Method 2: WP-CLI Installation

```bash
# Navigate to WordPress root
cd /path/to/wordpress

# Install plugin (if distributed via repository)
wp plugin install hvac-community-events --activate

# Or install from local file
wp plugin install /path/to/hvac-community-events.zip --activate

# Verify installation
wp plugin list --status=active
```

### Method 3: Composer Installation

```json
// composer.json
{
  "require": {
    "hvac/community-events": "^2.0"
  }
}
```

```bash
composer install
wp plugin activate hvac-community-events
```

### Post-Installation Verification

```bash
# Check plugin status
wp plugin verify hvac-community-events

# Run built-in diagnostics
wp eval 'HVAC_Plugin::run_diagnostics();'

# Check database tables
wp db query "SHOW TABLES LIKE '%hvac%';"
```

## Initial Configuration

### Step 1: Create Required Pages

```bash
# Run page creation script
wp eval 'HVAC_Page_Manager::create_required_pages();'
```

#### Required Pages Structure:
```
/trainer/
├── dashboard/
├── registration/
├── event/
│   ├── manage/
│   └── summary/
├── venue/
│   ├── list/
│   └── manage/
├── organizer/
│   ├── list/
│   └── manage/
├── training-leads/
└── certificate-reports/

/master-trainer/
├── master-dashboard/
├── trainers/
├── pending-approvals/
├── events/
├── announcements/
├── manage-announcements/
├── communication-templates/
└── google-sheets/

/community-login/
/find-trainer/
```

### Step 2: Configure Permalinks

```php
// WordPress Admin → Settings → Permalinks
// Select "Post name" structure
// Or programmatically:

function hvac_set_permalink_structure() {
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure('/%postname%/');
    $wp_rewrite->flush_rules();
}
add_action('init', 'hvac_set_permalink_structure');
```

### Step 3: Configure Basic Settings

Navigate to **HVAC Events → Settings**

```yaml
General Settings:
  Platform Name: "HVAC Community Events"
  Admin Email: "admin@example.com"
  Default Timezone: "America/New_York"
  
Registration Settings:
  Auto-Approve: false
  Email Verification: true
  Required Fields:
    - Company Name
    - Certification Number
    - Insurance Information
  
Event Settings:
  Default Duration: "8 hours"
  Max Capacity: "30"
  Registration Deadline: "24 hours before"
  Cancellation Policy: "48 hours notice"
```

### Step 4: Configure Dashboard Menus

```php
// Customize menu items in functions.php or custom plugin

add_filter('hvac_dashboard_menu_items', function($items) {
    // Add custom menu items
    $items['custom-reports'] = array(
        'title' => 'Custom Reports',
        'url' => '/trainer/custom-reports/',
        'capability' => 'hvac_trainer',
        'icon' => 'dashicons-chart-bar'
    );
    return $items;
});
```

## User Role Setup

### Creating Custom Roles

```php
// The plugin automatically creates these roles on activation
// Manual creation if needed:

function hvac_create_roles() {
    // Trainer Role
    add_role('hvac_trainer', 'HVAC Trainer', array(
        'read' => true,
        'edit_posts' => false,
        'delete_posts' => false,
        'publish_posts' => false,
        'upload_files' => true,
        'edit_tribe_events' => true,
        'delete_tribe_events' => true,
        'publish_tribe_events' => true,
        'edit_tribe_venues' => true,
        'delete_tribe_venues' => true,
        'publish_tribe_venues' => true,
        'edit_tribe_organizers' => true,
        'delete_tribe_organizers' => true,
        'publish_tribe_organizers' => true,
    ));
    
    // Master Trainer Role
    add_role('hvac_master_trainer', 'HVAC Master Trainer', array(
        'read' => true,
        'edit_posts' => false,
        'delete_posts' => false,
        'publish_posts' => false,
        'upload_files' => true,
        'edit_tribe_events' => true,
        'delete_tribe_events' => true,
        'publish_tribe_events' => true,
        'edit_others_tribe_events' => true,
        'delete_others_tribe_events' => true,
        'edit_tribe_venues' => true,
        'delete_tribe_venues' => true,
        'publish_tribe_venues' => true,
        'edit_tribe_organizers' => true,
        'delete_tribe_organizers' => true,
        'publish_tribe_organizers' => true,
        'manage_hvac_trainers' => true,
        'approve_hvac_trainers' => true,
        'edit_hvac_announcements' => true,
        'delete_hvac_announcements' => true,
    ));
}
add_action('init', 'hvac_create_roles');
```

### Assigning Roles

```bash
# Via WP-CLI
wp user add-role 15 hvac_trainer
wp user add-role 20 hvac_master_trainer

# List users with roles
wp user list --role=hvac_trainer
wp user list --role=hvac_master_trainer
```

### Role Capabilities Matrix

| Capability | Trainer | Master Trainer | Admin |
|------------|---------|----------------|-------|
| Create Events | ✓ | ✓ | ✓ |
| Edit Own Events | ✓ | ✓ | ✓ |
| Edit All Events | ✗ | ✓ | ✓ |
| Manage Venues | ✓ | ✓ | ✓ |
| Manage Organizers | ✓ | ✓ | ✓ |
| View Training Leads | ✓ | ✓ | ✓ |
| Approve Trainers | ✗ | ✓ | ✓ |
| Send Announcements | ✗ | ✓ | ✓ |
| Access Google Sheets | ✗ | ✓ | ✓ |
| System Settings | ✗ | ✗ | ✓ |

## The Events Calendar Integration

### Configuration Steps

1. **Install The Events Calendar**
   ```bash
   wp plugin install the-events-calendar --activate
   ```

2. **Configure TEC Settings**
   ```php
   // Navigate to Events → Settings
   
   General Tab:
   - Number of events to show per page: 30
   - Default Country: United States
   - Enable event views: List, Month, Day
   
   Display Tab:
   - Date Format: F j, Y
   - Time Format: g:i a
   - Show comments: No
   
   Template Tab:
   - Template Override: Plugin handles this
   ```

3. **Enable Plugin Integration**
   ```php
   // The HVAC plugin automatically integrates with TEC
   // Verify integration:
   wp eval 'echo HVAC_TEC_Integration::verify_integration() ? "Connected" : "Failed";'
   ```

### Custom Fields Integration

```php
// Add custom fields to TEC events
add_action('tribe_events_meta_box', function() {
    ?>
    <div class="hvac-custom-fields">
        <label>Certification Type:</label>
        <select name="hvac_certification_type">
            <option value="nate">NATE</option>
            <option value="epa">EPA Section 608</option>
            <option value="other">Other</option>
        </select>
        
        <label>CE Credits:</label>
        <input type="number" name="hvac_ce_credits" min="0" max="8">
    </div>
    <?php
});
```

## Venue and Organizer Setup

### Venue Management Configuration

```php
// Enable venue features
add_filter('hvac_venue_features', function($features) {
    return array(
        'enable_map' => true,
        'require_address' => true,
        'enable_capacity' => true,
        'enable_amenities' => true,
        'enable_parking_info' => true,
        'enable_accessibility' => true,
    );
});
```

### Default Venue Fields

```yaml
Required Fields:
  - Venue Name
  - Address
  - City
  - State/Province
  - ZIP/Postal Code
  - Country

Optional Fields:
  - Phone
  - Website
  - Capacity
  - Parking Information
  - Accessibility Features
  - Equipment Available
  - Venue Image
```

### Organizer Configuration

```php
// Set organizer defaults
update_option('hvac_organizer_defaults', array(
    'require_logo' => false,
    'require_website' => true,
    'require_phone' => true,
    'enable_social_links' => true,
    'max_logo_size' => 2048000, // 2MB
));
```

## Email Configuration

### SMTP Setup

```php
// wp-config.php
define('HVAC_SMTP_HOST', 'smtp.example.com');
define('HVAC_SMTP_PORT', 587);
define('HVAC_SMTP_USER', 'notifications@example.com');
define('HVAC_SMTP_PASS', 'secure_password');
define('HVAC_SMTP_FROM', 'HVAC Community Events');
define('HVAC_SMTP_FROM_EMAIL', 'noreply@example.com');
```

### Email Templates Configuration

Navigate to **Master Trainer → Communication Templates**

```yaml
Default Templates:
  welcome_trainer:
    subject: "Welcome to HVAC Community Events"
    trigger: "On trainer approval"
    
  event_confirmation:
    subject: "Event Registration Confirmed"
    trigger: "On successful registration"
    
  event_reminder:
    subject: "Upcoming Training Reminder"
    trigger: "24 hours before event"
    
  certificate_ready:
    subject: "Your Certificate is Ready"
    trigger: "On certificate generation"
```

### Email Queue Configuration

```php
// Enable email queue for better performance
define('HVAC_USE_EMAIL_QUEUE', true);
define('HVAC_EMAIL_BATCH_SIZE', 50);
define('HVAC_EMAIL_SEND_INTERVAL', 300); // 5 minutes
```

## Security Configuration

### Essential Security Settings

```php
// wp-config.php security hardening

// Force SSL for admin
define('FORCE_SSL_ADMIN', true);

// Disable file editing
define('DISALLOW_FILE_EDIT', true);

// Security keys (generate from https://api.wordpress.org/secret-key/1.1/salt/)
define('AUTH_KEY', 'unique-phrase-here');
define('SECURE_AUTH_KEY', 'unique-phrase-here');
define('LOGGED_IN_KEY', 'unique-phrase-here');
define('NONCE_KEY', 'unique-phrase-here');

// HVAC-specific security
define('HVAC_ENFORCE_SSL', true);
define('HVAC_SESSION_TIMEOUT', 3600); // 1 hour
define('HVAC_MAX_LOGIN_ATTEMPTS', 5);
define('HVAC_LOCKOUT_DURATION', 900); // 15 minutes
```

### File Upload Security

```php
// Configure allowed file types
add_filter('hvac_allowed_upload_types', function($types) {
    return array(
        'jpg|jpeg' => 'image/jpeg',
        'png' => 'image/png',
        'pdf' => 'application/pdf',
        'doc|docx' => 'application/msword',
    );
});

// Set upload limits
add_filter('hvac_upload_limits', function($limits) {
    return array(
        'max_file_size' => 5242880, // 5MB
        'max_files_per_user' => 100,
        'scan_uploads' => true, // Virus scanning if available
    );
});
```

### Database Security

```sql
-- Create dedicated database user for the plugin
CREATE USER 'hvac_user'@'localhost' IDENTIFIED BY 'strong_password';

-- Grant only necessary permissions
GRANT SELECT, INSERT, UPDATE, DELETE ON wordpress.wp_hvac_* TO 'hvac_user'@'localhost';
GRANT SELECT ON wordpress.wp_users TO 'hvac_user'@'localhost';
GRANT SELECT ON wordpress.wp_usermeta TO 'hvac_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON wordpress.wp_posts TO 'hvac_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON wordpress.wp_postmeta TO 'hvac_user'@'localhost';

FLUSH PRIVILEGES;
```

## Performance Optimization

### Caching Configuration

```php
// Enable object caching
define('WP_CACHE', true);

// Redis configuration
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_DATABASE', 0);

// HVAC-specific caching
define('HVAC_CACHE_ENABLED', true);
define('HVAC_CACHE_DURATION', 3600); // 1 hour
define('HVAC_CACHE_EVENTS', true);
define('HVAC_CACHE_TRAINERS', true);
define('HVAC_CACHE_VENUES', true);
```

### Database Optimization

```sql
-- Add indexes for better performance
ALTER TABLE wp_hvac_certificates ADD INDEX idx_trainer_id (trainer_id);
ALTER TABLE wp_hvac_certificates ADD INDEX idx_event_id (event_id);
ALTER TABLE wp_hvac_certificates ADD INDEX idx_created_date (created_date);

ALTER TABLE wp_posts ADD INDEX idx_hvac_events (post_type, post_status, post_date);

-- Optimize tables regularly
OPTIMIZE TABLE wp_hvac_certificates;
OPTIMIZE TABLE wp_posts;
OPTIMIZE TABLE wp_postmeta;
```

### CDN Configuration

```php
// CDN settings for static assets
define('HVAC_CDN_URL', 'https://cdn.example.com');
define('HVAC_CDN_INCLUDES', array('css', 'js', 'images'));

add_filter('hvac_asset_url', function($url) {
    if (defined('HVAC_CDN_URL')) {
        return str_replace(home_url(), HVAC_CDN_URL, $url);
    }
    return $url;
});
```

## Backup and Recovery

### Automated Backup Setup

```bash
#!/bin/bash
# backup-hvac.sh

# Configuration
BACKUP_DIR="/backups/hvac"
MYSQL_USER="backup_user"
MYSQL_PASS="secure_password"
DB_NAME="wordpress"
WP_PATH="/var/www/wordpress"
DATE=$(date +%Y%m%d_%H%M%S)

# Create backup directory
mkdir -p $BACKUP_DIR/$DATE

# Backup database
mysqldump -u $MYSQL_USER -p$MYSQL_PASS $DB_NAME \
    --tables wp_hvac_certificates \
    wp_posts wp_postmeta wp_users wp_usermeta \
    wp_term_relationships wp_term_taxonomy wp_terms \
    > $BACKUP_DIR/$DATE/database.sql

# Backup plugin files
tar -czf $BACKUP_DIR/$DATE/plugin.tar.gz \
    -C $WP_PATH/wp-content/plugins hvac-community-events

# Backup uploads
tar -czf $BACKUP_DIR/$DATE/uploads.tar.gz \
    -C $WP_PATH/wp-content uploads/hvac

# Clean old backups (keep 30 days)
find $BACKUP_DIR -type d -mtime +30 -exec rm -rf {} \;
```

### Recovery Procedures

```bash
#!/bin/bash
# restore-hvac.sh

# Configuration
BACKUP_DATE="20250828_120000"
BACKUP_DIR="/backups/hvac/$BACKUP_DATE"
WP_PATH="/var/www/wordpress"

# Restore database
mysql -u root -p wordpress < $BACKUP_DIR/database.sql

# Restore plugin files
tar -xzf $BACKUP_DIR/plugin.tar.gz -C $WP_PATH/wp-content/plugins/

# Restore uploads
tar -xzf $BACKUP_DIR/uploads.tar.gz -C $WP_PATH/wp-content/

# Clear cache
wp cache flush

# Regenerate permalinks
wp rewrite flush
```

## Troubleshooting

### Common Installation Issues

#### Issue: Plugin activation fails

```bash
# Check PHP error log
tail -f /var/log/php/error.log

# Enable WordPress debug
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

# Check plugin compatibility
wp plugin verify-checksums hvac-community-events
```

#### Issue: Pages not created

```bash
# Manually create pages
wp eval 'HVAC_Page_Manager::create_required_pages();'

# Verify page creation
wp post list --post_type=page --meta_key=_hvac_page --fields=ID,post_title,post_name
```

#### Issue: Roles not working

```php
// Reset roles and capabilities
function hvac_reset_roles() {
    remove_role('hvac_trainer');
    remove_role('hvac_master_trainer');
    
    HVAC_Roles::create_roles();
    HVAC_Roles::add_capabilities();
}
hvac_reset_roles();
```

### Database Issues

```sql
-- Check for missing tables
SHOW TABLES LIKE 'wp_hvac%';

-- Recreate tables if missing
CREATE TABLE IF NOT EXISTS wp_hvac_certificates (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    certificate_number varchar(50) NOT NULL,
    trainer_id bigint(20) unsigned NOT NULL,
    event_id bigint(20) unsigned NOT NULL,
    attendee_name varchar(255) NOT NULL,
    attendee_email varchar(255) NOT NULL,
    completion_date datetime NOT NULL,
    created_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY certificate_number (certificate_number),
    KEY trainer_id (trainer_id),
    KEY event_id (event_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

### Performance Issues

```bash
# Check slow queries
mysqldumpslow -s t /var/log/mysql/slow-query.log

# Monitor resource usage
top -u www-data
htop

# Check WordPress performance
wp doctor check
```

## Maintenance Procedures

### Daily Maintenance Tasks

```bash
#!/bin/bash
# daily-maintenance.sh

# Clear transients
wp transient delete --expired

# Optimize database
wp db optimize

# Check for plugin updates
wp plugin update --all --dry-run

# Monitor error logs
tail -n 100 /var/log/wordpress/error.log | grep -i "hvac"

# Check disk usage
df -h | grep -E "/$|/var"
```

### Weekly Maintenance

```bash
# Full backup
/scripts/backup-hvac.sh

# Security scan
wp security scan

# Check broken links
wp link-checker check

# Review user activity
wp user activity --role=hvac_trainer --days=7
```

### Monthly Maintenance

```bash
# Full system audit
wp system audit

# Database optimization
mysqlcheck -o wordpress -u root -p

# Review and clean logs
find /var/log -name "*.log" -mtime +30 -delete

# Update documentation
git commit -am "Monthly documentation update"
```

## Migration Guide

### Migrating from Another System

#### Pre-Migration Checklist

- [ ] Backup source system completely
- [ ] Export user data in CSV format
- [ ] Export event data
- [ ] Document custom configurations
- [ ] Test migration in staging environment
- [ ] Plan downtime window
- [ ] Notify users of migration

#### Data Import Process

```php
// Import trainers from CSV
function hvac_import_trainers($csv_file) {
    $handle = fopen($csv_file, 'r');
    $headers = fgetcsv($handle);
    
    while (($data = fgetcsv($handle)) !== FALSE) {
        $user_data = array_combine($headers, $data);
        
        $user_id = wp_insert_user(array(
            'user_login' => sanitize_user($user_data['username']),
            'user_email' => sanitize_email($user_data['email']),
            'user_pass' => wp_generate_password(),
            'first_name' => sanitize_text_field($user_data['first_name']),
            'last_name' => sanitize_text_field($user_data['last_name']),
            'role' => 'hvac_trainer'
        ));
        
        if (!is_wp_error($user_id)) {
            // Add custom meta
            update_user_meta($user_id, 'hvac_company', $user_data['company']);
            update_user_meta($user_id, 'hvac_certification', $user_data['certification']);
            
            // Send welcome email
            wp_new_user_notification($user_id, null, 'both');
        }
    }
    
    fclose($handle);
}
```

### Server Migration

```bash
#!/bin/bash
# migrate-hvac.sh

# Source server
SOURCE_HOST="old-server.com"
SOURCE_PATH="/var/www/wordpress"
SOURCE_DB="wordpress_old"

# Destination server
DEST_PATH="/var/www/wordpress"
DEST_DB="wordpress_new"

# Sync files
rsync -avz --exclude='wp-config.php' \
    $SOURCE_HOST:$SOURCE_PATH/ $DEST_PATH/

# Export database
ssh $SOURCE_HOST "mysqldump $SOURCE_DB" > backup.sql

# Import database
mysql $DEST_DB < backup.sql

# Update URLs
wp search-replace 'https://old-domain.com' 'https://new-domain.com'

# Clear cache
wp cache flush
```

## API Configuration

### REST API Endpoints

```php
// Enable custom endpoints
add_action('rest_api_init', function() {
    register_rest_route('hvac/v1', '/trainers', array(
        'methods' => 'GET',
        'callback' => 'hvac_api_get_trainers',
        'permission_callback' => '__return_true',
    ));
    
    register_rest_route('hvac/v1', '/events', array(
        'methods' => 'GET',
        'callback' => 'hvac_api_get_events',
        'permission_callback' => '__return_true',
    ));
    
    register_rest_route('hvac/v1', '/register', array(
        'methods' => 'POST',
        'callback' => 'hvac_api_register_trainer',
        'permission_callback' => '__return_true',
    ));
});
```

### API Authentication

```php
// Configure API authentication
define('HVAC_API_KEY', 'your-secure-api-key');

function hvac_api_authenticate($request) {
    $api_key = $request->get_header('X-HVAC-API-Key');
    
    if ($api_key !== HVAC_API_KEY) {
        return new WP_Error(
            'rest_forbidden',
            'Invalid API key',
            array('status' => 401)
        );
    }
    
    return true;
}
```

### Webhook Configuration

```php
// Configure webhooks for events
add_action('hvac_trainer_approved', function($trainer_id) {
    $webhook_url = get_option('hvac_webhook_trainer_approved');
    
    if ($webhook_url) {
        wp_remote_post($webhook_url, array(
            'body' => json_encode(array(
                'trainer_id' => $trainer_id,
                'timestamp' => current_time('mysql'),
            )),
            'headers' => array(
                'Content-Type' => 'application/json',
            ),
        ));
    }
});
```

---

## Quick Reference

### Essential Commands

```bash
# Plugin management
wp plugin activate hvac-community-events
wp plugin deactivate hvac-community-events
wp plugin verify hvac-community-events

# User management
wp user list --role=hvac_trainer
wp user add-role USER_ID hvac_trainer
wp user remove-role USER_ID hvac_trainer

# Cache management
wp cache flush
wp transient delete --all

# Database management
wp db optimize
wp db repair
wp db export backup.sql
wp db import backup.sql

# Troubleshooting
wp doctor check
wp config get
wp debug
```

### Configuration Files

```
/wp-content/plugins/hvac-community-events/
├── hvac-community-events.php    # Main plugin file
├── includes/                    # Core classes
├── templates/                    # Template files
├── assets/                      # CSS, JS, images
├── languages/                   # Translations
└── docs/                        # Documentation
```

### Support Resources

- **Documentation**: `/docs/` directory
- **Error Logs**: `/wp-content/debug.log`
- **Support Email**: support@hvac-events.com
- **GitHub Issues**: [Repository Issues Page]
- **Community Forum**: [Forum URL]

---

*This guide is maintained by the HVAC Community Events development team. For updates or corrections, please submit a pull request or contact the development team.*

**Document Version**: 2.0.0  
**Plugin Version**: 2.0.0  
**Last Updated**: August 28, 2025