Home / Admin / WP Simple Pay: Add Email Address to Payment Confirmation URL
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Add Email Address to Payment Confirmation URL

Append the submitted email address to the payment confirmation page URL.

Code Preview
php
<?php
add_action(
	'template_redirect',
	function() {
		if ( ! function_exists( '\SimplePay\Core\Payments\Payment_Confirmation\get_confirmation_data' ) ) {
			return;
		}
		
		$data = \SimplePay\Core\Payments\Payment_Confirmation\get_confirmation_data();
		if ( empty( $data ) ) {
			return;
		}
		$customer = $data['customer'];
		$email = $customer->email;
		
		if ( isset( $_GET['email'] ) ) {
			return;
		}
		
		wp_safe_redirect( add_query_arg( 'email', $email ) );
	}
);

Comments

Add a Comment