Home / Archive / MemberPress: Pass a Member Phone Number to Stripe
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Pass a Member Phone Number to Stripe

This code will pass the phone number a member added to the membership registration form when signing up to Stripe. As a result, the member’s phone number will be saved in the customer profile on Stripe.

The sample code uses the “mepr_phone” slug on line 2 for the phone number field. This slug needs to match the slug of the phone custom field used in the registration form to collect the phone number.

Code Preview
php
<?php
function mepr_pass_phone_number_to_stripe( $args, $user ) {
    $phone = get_user_meta( $user->ID, 'mepr_phone', true );
    if ( ! empty( $phone ) ) {
        $args['phone'] = $phone;
    }
    return $args;
}
add_filter( 'mepr_stripe_create_customer_args', 'mepr_pass_phone_number_to_stripe', 10, 2 );

Comments

Add a Comment