How to Store the Credit Cardholder Name In Entries


Would you like to store the credit cardholder’s name inside your WPForms entry? The cardholder’s name isn’t always the same as the user completing the form and you may wish to retain this information. Using a small PHP snippet you can easily achieve this.

Creating the form

First, you’ll need to create a new form that will accept Stripe payments. If you need any help with creating this type of form, please check out this documentation.

create your form and enable the settings to accept Stripe payments

Adding the snippet

Next, you’ll need to add this snippet to your site.

If you’re not sure how to add snippets to your site, please review this tutorial.

 * Store credit card name and last 4 digits of the credit card
 * @link

function wpf_dev_credit_card_save_cardholder( $value, $charge ) {

    $value  = $charge->source->name . "\n"; // card holder name
    $value .= 'XXXXXXXXXXXX' . $charge->source->last4 . "\n"; // last 4 card numbers
    $value .= $charge->source->brand; // type of card (visa/AMEX etc)

    return $value;
add_filter( 'wpforms_stripe_creditcard_value', 'wpf_dev_credit_card_save_cardholder', 10, 2 );

The above snippet will capture the cardholder’s name and the last 4 digits on the Stripe Credit Card field and store them inside the form entry.

Now you can store the credit cardholder name and the last 4 digits of the card inside the form entry

And that’s all you need to save the name in your entry. Would you like to add a unique ID number to each form entry? Take a look at our article on How to Create a Unique ID for Each Form Entry.

Filter Reference: wpforms_stripe_creditcard_value