| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Give\DonorDashboards; |
| 4 | 4 | |
| 5 | -use Give\Donors\Models\Donor; | |
| 6 | 5 | use WP_User; |
| 7 | 6 | |
| 8 | 7 | /** |
| 9 | 8 | * @since 2.10.0 |
| @@ -12,8 +11,9 @@ | ||
| 12 | 11 | { |
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | 14 | * Retrieve the current donor ID from based on session |
| 15 | + * @since 4.16.8.1 Guard against get_donor_by() finding no matching donor for the token's email. | |
| 16 | 16 | * @since 2.10.0 |
| 17 | 17 | */ |
| 18 | 18 | public static function getCurrentDonorId() |
| 19 | 19 | { |
| @@ -30,9 +30,11 @@ | ||
| 30 | 30 | |
| 31 | 31 | if ($useToken) { |
| 32 | 32 | $donor = give()->donors->get_donor_by('email', give()->email_access->token_email); |
| 33 | 33 | |
| 34 | - return $donor->id; | |
| 34 | + if ($donor) { | |
| 35 | + return $donor->id; | |
| 36 | + } | |
| 35 | 37 | } |
| 36 | 38 | } |
| 37 | 39 | |
| 38 | 40 | return null; |