Issue
-
Hi WPGens team,
Reporting a reproducible fatal in the My Account → Refer a Friend tab. Wanted to flag it in case it’s not already on your radar.
Plugin: WPGens Refer A Friend Premium
File:includes/class-wpgens-raf-myaccount.php
Line: 242Error:
Uncaught Error: Call to a member function get_email() on boolRoot cause:
In
prepare_friends(), the user-lookup block at lines 236–246 checks$order->get_user_id()before fetching the user object, but doesn’t guard against$order->get_user()returningfalse:if ($order->get_user_id()) { $user = $order->get_user(); if (!empty($user->first_name)) { $user = $user->first_name . ' ' . $user->last_name; } else { $user = $user->get_email(); // fatals when $user is false } }If an order’s
_customer_usermeta points to a user ID that no longer exists inwp_users(deleted customer account, GDPR removal, bulk cleanup, etc.),get_user_id()still returns the orphan ID (truthy), butget_user()returnsfalse. Theelsebranch then calls->get_email()onfalse→ fatal, and the entire My Account page 500s for any logged-in user whose referral history includes such an order.In one site I looked at, ~140 orphan orders across ~20 deleted users were enough to make the page completely unusable.
Proposed fix:
Add a
!$userguard before thefirst_namecheck:if ($order->get_user_id()) { $user = $order->get_user(); if (!$user) { $user = __('Guest (deleted user)', 'gens-raf'); } elseif (!empty($user->first_name)) { $user = $user->first_name . ' ' . $user->last_name; } else { $user = $user->get_email(); } } else { $user = __('Guest', 'gens-raf'); }Happy to provide additional info if useful. Thanks for the great plugin!
You must be logged in to reply to this topic.