| @@ -361,9 +361,22 @@ | ||
| 361 | 361 | * |
| 362 | 362 | * @return int |
| 363 | 363 | */ |
| 364 | 364 | public static function get_user_id_for_current_payment() { |
| 365 | - return is_user_logged_in() ? get_current_user_id() : 0; | |
| 365 | + $user_id = is_user_logged_in() ? get_current_user_id() : 0; | |
| 366 | + | |
| 367 | + /** | |
| 368 | + * Set the user who owns the payment being made. | |
| 369 | + * This makes it possible for an add on to claim the payment for a user who isn't logged in yet, | |
| 370 | + * for example when the same submission registers them. | |
| 371 | + * | |
| 372 | + * @since 6.35 | |
| 373 | + * | |
| 374 | + * @param int $user_id The logged in user, or 0 for a guest. | |
| 375 | + */ | |
| 376 | + $user_id = (int) apply_filters( 'frm_payment_user_id', $user_id ); | |
| 377 | + | |
| 378 | + return max( 0, $user_id ); | |
| 366 | 379 | } |
| 367 | 380 | |
| 368 | 381 | /** |
| 369 | 382 | * @param int $user_id |