fix(products): plan editor pins Customer Role to resolved default, overriding global Default Role

Chiusa
#2,081 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #2082 di @superdav42 — integrata

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php, wordpress
Ambito
backend

Direzione di ricerca

Read inc/admin-pages/class-product-edit-admin-page.php around line 757 and inc/limitations/class-limit-customer-user-role.php around line 74 to understand how the plan editor gets the customer role. The issue describes the fix: show the stored value, falling back to default; check that saving an untouched plan preserves default and that existing explicit roles remain visible. Pull request #2082 is already open against this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug origin:interactive status:available

Problem

Customer reports that with Settings → Login & Registration → Default Role set to a custom role ("CRM Admin"), new customers are still added to their site as Administrator.

Root cause

The plan editor's Customer Role select (inc/admin-pages/class-product-edit-admin-page.php:757) uses Product::get_customer_role(), which resolves an unset/default limit to the current global default_role (inc/limitations/class-limit-customer-user-role.php:74). So "Use Ultimate Multisite default" is never shown as selected; the select shows the resolved role (administrator out of the box). Saving the plan then stores that role explicitly, and Site::save() (inc/models/class-site.php:2238-2241) prefers the plan's role over the global setting from then on. Changing Default Role later has no effect on that plan.

Fix

Show the stored value in the editor, falling back to default, so saving a plan without touching the field keeps following the global setting.

Verification

Dev network, global Default Role later switched to WooCommerce shop_manager, site cloned from template via pending-site publish:

  • Plan saved with the old editor value → stored administrator → customer gets administrator.
  • Plan saved with the patched editor value → stored default → customer gets shop_manager.

Existing plans that already have an explicit role keep it; the editor now displays it so admins can switch to "Use Ultimate Multisite default".

Lingua principale
PHP
Stelle
218
Fork
88
Merge medio
1g 5h
PR unite (30g)
94

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Ultimate-Multisite/ultimate-multisite

Tutte le issue di Ultimate-Multisite/ultimate-multisite

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.