From 252903a2279a85397f83234d81a302c4285940b0 Mon Sep 17 00:00:00 2001 From: Flint Date: Wed, 11 Mar 2026 20:11:36 -0400 Subject: [PATCH] BUG: Add null check for $pmpro_level in pmproga4_checkout_events() Fixes a PHP warning 'Attempt to read property on null' thrown when $pmpro_level is not populated on the checkout page. This can happen when bots, crawlers, or redirects hit the checkout URL without a valid level context. Added an early return guard to prevent accessing properties on a null object. --- includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index f2ebe00..b18d4d6 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -213,6 +213,11 @@ function pmproga4_checkout_events() { return; } + // Bail if the membership level is not set. + if ( empty( $pmpro_level ) ) { + return; + } + // Build an array of product data. $gtag_config_ecommerce_products = array(); $gtag_config_ecommerce_products['item_id'] = $pmpro_level->id;