• Resolved shelleyweb

    (@espressivo)


    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: 242

    Error:

    Uncaught Error: Call to a member function get_email() on bool

    Root 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() returning false:

    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_user meta points to a user ID that no longer exists in wp_users (deleted customer account, GDPR removal, bulk cleanup, etc.), get_user_id() still returns the orphan ID (truthy), but get_user() returns false. The else branch then calls ->get_email() on false → 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 !$user guard before the first_name check:

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author petervukovic

    (@petervukovic)

    Hi @espressivo ,

    thank you for the detailed issue report for our premium version of the plugin.

    We just fixed the issue and released an updated version (v 4.4.9), so please update the plugin on your end.

    Feel free to let us know if you spot anything else!

    Thread Starter shelleyweb

    (@espressivo)

    Fantastic, thank you

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.