Skip to content

Commit e5ca718

Browse files
authored
fix(membership): show missing membership field notice only when at least one active membership exists (#1359)
1 parent fc6d080 commit e5ca718

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

modules/membership/includes/Admin/Services/MembershipService.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,13 @@ private static function verify_membership_registration_form_shortcode( $post, $r
548548
}
549549
}
550550

551-
$response['status'] = $membership_field_exists;
552-
$response['message'] = ! $membership_field_exists ? __( 'The selected page consist a User Registration & Membership Form but no membership field.', 'user-registration' ) : '';
551+
// Warn only when at least one active membership exists, since the field is
552+
// pointless with none (see UR-4604).
553+
$active_memberships_count = count( ( new MembershipRepository() )->get_all_membership() );
554+
$show_notice = ! $membership_field_exists && $active_memberships_count >= 1;
555+
556+
$response['status'] = ! $show_notice;
557+
$response['message'] = $show_notice ? __( 'The selected page consist a User Registration & Membership Form but no membership field.', 'user-registration' ) : '';
553558
$response['disable_save_btn'] = 'no';
554559

555560
return $response;

0 commit comments

Comments
 (0)