Skip to content

UR-4832 Feat - Add "Always Show This Field" toggle in membership field advance settings - #1395

Open
MILAN88888 wants to merge 1 commit into
developfrom
UR-4832-add-always-show-this-field-toggle-in-membership-field
Open

UR-4832 Feat - Add "Always Show This Field" toggle in membership field advance settings#1395
MILAN88888 wants to merge 1 commit into
developfrom
UR-4832-add-always-show-this-field-toggle-in-membership-field

Conversation

@MILAN88888

@MILAN88888 MILAN88888 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

https://themegrill.atlassian.net/browse/UR-4832

Adds an Always Show This Field toggle (default on) to the Membership field's Advance Settings. Turning it off hides the whole membership field on the frontend when there is only one active plan and that plan is free.

The toggle only has an effect in that case, so it is only rendered in that case - the setting resolves the field's own plan list (all / group / selected) and is registered only when it comes back as a single free plan. Otherwise the Advanced Settings section is not shown for this field at all.

Condition:

$single_membership   = 1 === count( $memberships ) ? reset( $memberships ) : null;
$is_single_free_plan = null !== $single_membership && 'free' === ( $single_membership['type'] ?? 'free' );
$single_plan         = ( ! $always_show_membership_field && $is_single_free_plan ) ? $single_membership : null;

type comes from build_membership_list_frontend(), which sets it from the plan meta as free, paid or subscription — so only free collapses; a single paid/subscription plan renders as normal.

When it collapses, the outer #ur-membership-registration wrapper is hidden so the plan list, coupon, total and gateways go together. The plan radio stays in the DOM and checked (not swapped for a hidden input) because the frontend JS reads the selection via input[name="urm_membership"]:checked.

Also needed to make the setting reachable:

  • Hooked user_registration_membership_advance_class — the loader only auto-includes from core includes/form/settings/, so the module's settings class never loaded and the Advanced Settings section never rendered for this field.
  • Dropped that class's redundant field_name setting — sweep_array() treats every field_name as a global unique key, so it collided with general_setting.field_name and blocked form saves.

#1386 (UR-4788) is left intact and is a separate layer: any lone plan still auto-selects and renders as a static summary with its radio hidden. This PR only adds the further step of hiding the field outright, and only for a lone free plan with the toggle off.

Also completes UR-4788's label rename that was missed in class-ur-ajax.php - the auto-created default form and the "add membership field to existing form" helper still hardcoded "label":"Membership Field", so new installs got the old label even though default_label was already Membership.

Closes # .

How to test the changes in this Pull Request:

  1. With exactly one active plan of type Free, open a form with a Membership field → Field Options → Advanced Settings and confirm Always Show This Field shows, on by default. Save the form.
  2. Point the same field at two or more plans (or at a single paid plan) and confirm the toggle - and the Advanced Settings section - is not offered.
  3. Frontend with toggle on — field renders as usual.
  4. Turn it off, save, reload — the whole membership field (label, plan, Total, coupon, gateways) is gone.
  5. Register and confirm the user gets the free plan with an Active subscription.
  6. Regression (UR-4810 Fix fatal error: array_key_exists() receives null instead of array in form validation during subscription registration #1386): with one plan of any type, the plan still renders without a radio, auto-selected; with two or more plans the radios are selectable as usual.
  7. Create a fresh default registration form and confirm the membership field label reads Membership.

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully ran tests with your changes locally?
  • Have you updated the documentation accordingly?

Changelog entry

Feature - Add an "Always Show This Field" option to the Membership field to hide the field on the frontend when the only active plan is free.

@MILAN88888 MILAN88888 self-assigned this Aug 18, 2026
@MILAN88888
MILAN88888 force-pushed the UR-4832-add-always-show-this-field-toggle-in-membership-field branch 2 times, most recently from 31b2869 to 76b23f2 Compare August 18, 2026 04:28
@MILAN88888
MILAN88888 force-pushed the UR-4832-add-always-show-this-field-toggle-in-membership-field branch from 76b23f2 to c50d356 Compare August 18, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant