# CC Soccer D11 - Session Handoff
**Date:** February 15, 2026
**Session:** Field Visibility Fix & UI Modernization (Phases 1–2)
**Branch:** main

---

## Summary

Two areas of work this session:

1. **UI Modernization Phases 1 & 2** (committed as `7381f13`): Created a design token system (118 CSS custom properties) and unified base component styles across 14+ CSS files. Phase 2 added mobile-first schedule improvements, form styling, status badges, micro-animations, and navigation enhancements. Phase 3 (dark mode, loading states, drag-drop) was explored but deferred — Phases 1 & 2 are sufficient for now.

2. **Field Visibility Fix**: Investigated and fixed admin-only skill level fields (`field_skill_level`) being visible to players on the `/user/register` page. Added form alter hooks to hide admin-only fields from both the registration form and the user profile edit form for non-admin users.

---

## What Was Completed

### 1. Hide Admin Fields from Player-Facing Forms

**File:** `ccsoccer.module`

**`ccsoccer_form_user_register_form_alter()`** (line ~1206)
- Previously empty (TODO stub). Now hides admin-only fields from the Create New Account form:
  - `field_skill_level` — Admin-set skill level (1-10), assigned via All Players AJAX interface
  - `field_self_score` — Collected during first season checkout via PlayerInfoPane, not at account creation
  - `field_credits_balance` — Admin-managed credits
  - `field_discount_percent` — Admin-managed discount
  - `field_has_jersey` — Tracked automatically via checkout flow
- Uses `$form[$field_name]['#access'] = FALSE` to completely hide fields

**`ccsoccer_form_user_form_alter()`** (line ~1239) — **NEW**
- Hides the same admin-only fields from regular players on the user profile edit form
- Users with `manage seasons` or `administer users` permission can still see all fields
- Ensures players can't view or modify admin-managed data when editing their profile

### 2. Verification: Self-Assessment Score Behavior

**File:** `src/Plugin/Commerce/CheckoutPane/PlayerInfoPane.php`
- Confirmed working as designed: `isVisible()` calls `isFirstTimeRegistration()` which checks for any prior season registrations
- The Self-Assessment Score drag bar (1-5 range) only appears during first-time season checkout
- After order completion, `OrderCompleteSubscriber` saves `field_self_score` to the user entity only if the field is currently empty

### 3. Skill Priority Chain (Reference)

From `TeamBalancerService::getPlayerSkill()`:
1. Admin-assigned `field_skill_level` (1-10) — highest priority
2. Self-assessed `field_self_score` (1-5) — fallback
3. Default value: 3 — if neither is set

---

## TODOs

### 🔴 Duplicate Picture Fields on User Registration
The Create New Account page shows **two** picture upload fields:
- `field_player_picture` — Custom field: "Please use an actual recent photo of yourself featuring your face." (1 MB limit, png/jpg/jpeg)
- `user_picture` — Drupal's built-in user picture: "Your virtual face or picture." (100 MB limit, png/gif/jpg/jpeg/webp)

All existing code (`SeasonController`, `TournamentController`, `PlayerAdminController`) reads from `user_picture` only. `field_player_picture` is not referenced anywhere in module PHP code.

**Decision needed:** Remove `field_player_picture` from the form, or migrate code to use it instead of `user_picture`. The custom field has stricter validation (1 MB, fewer formats) which may be preferable.

### 🔴 Photo Face Validation
Implement validation to ensure uploaded player photos actually contain a human face and not arbitrary images. The `field_player_picture` description already says "Please use an actual recent photo of yourself featuring your face" but there is no server-side enforcement. Options:
- Use a face detection library/API during upload validation
- Add a custom `#element_validate` callback on the image field
- Use a third-party service (e.g., AWS Rekognition, Google Vision API) to verify face presence

### 🟡 Registration Form Custom Fields
The `ccsoccer_form_user_register_form_alter()` hook still has a TODO for adding required fields:
- DOB (required, 18+ validation)
- Gender
- Phone
- Picture (required)

### 🟡 CC Soccer Logo
The old D7 site had a CC Soccer logo in the header/footer that linked to home. The D11 site uses the default Drupal logo. Andrew needs to provide the logo image file — Olivero theme already supports logo-links-to-home functionality via Appearance settings.

---

## For Andrew

After pulling:
1. `ddev drush cr` — Clear cache to pick up the new form alter hooks
2. Visit `/user/register` (logged out or as non-admin) to verify `field_skill_level` is no longer visible
3. Visit `/user/[uid]/edit` as a regular player to verify admin fields are hidden

---

## Files Modified

| File | Changes |
|------|---------|
| `ccsoccer.module` | `ccsoccer_form_user_register_form_alter()` — populated with admin field hiding; `ccsoccer_form_user_form_alter()` — **NEW** hook for user edit form |

---

## Previous Session Archive

Archived to: `archive/SESSION_HANDOFF_2026_02_13_migration.md`

---

**Session Status:** ✅ **COMPLETE** — Ready to commit
