Skip to content
Docs
Get RestroPress

Filter

rpress_payment_user_id

Updated
On this page

Filters the WordPress user ID returned for a payment.

Runs when the WordPress user ID linked to the order (0 for guests) property is read from an RPRESS_Payment object (for example $payment->user_id), through the object's magic getter. Reads made inside the class itself go straight to the property and are not filtered.

Parameters#

ParameterTypeDescription
$user_idintThe value loaded for the payment.
$payment_idintThe payment (order) ID.
$paymentRPRESS_PaymentThe payment object being read.

Return value#

int. The (possibly modified) value returned for the property.

Example#

add_filter( 'rpress_payment_user_id', 'my_match_payment_user_by_email', 10, 3 );
function my_match_payment_user_by_email( $user_id, $payment_id, $payment ) {
	if ( empty( $user_id ) ) {
		$user = get_user_by( 'email', $payment->email );
		if ( $user ) {
			return (int) $user->ID;
		}
	}
	return $user_id;
}

Source#

Applied in:

  • includes/payments/class-rpress-payment.php (line 2276), in RPRESS_Payment::get_user_id()

See also#

Was this page helpful?