PHP 8+ throws `Undefined array key "level-1_label"`

s2Member Missing Level Label Fix (2026-02-10)

Issue: PHP 8+ throws Undefined array key "level-1_label" in s2member/src/includes/classes/constants.inc.php around line 294. This can lead to shutdown-level errors.

Fix applied: Add a fallback for missing level{n}_label and log once. Implemented as a MU-plugin to survive s2Member updates.

Suggested upstream fix for s2Member core:

  • Replace direct access of $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$level.'_label'] with a safe fallback:

  • $level_label = $GLOBALS['WS_PLUGIN__']['s2member']['o'][$level_label_key] ?? ('Level '.$level);

  • Then define the constant using $level_label.

  • Optional: log once if the label is missing.

1 Like

Thanks for reporting that! I’ll look into it.

:slight_smile:

I think I fixed this. Please try the attached zip and let me know if it solved that.

s2member-v260224.73402.zip (1.4 MB)

:slight_smile: