Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Forked from ideadude/my_require_cvv_for_reals.php
Last active February 15, 2019 13:25
Show Gist options
  • Save andrewlimaza/1510ac5795edab55c5a21c978e3b3716 to your computer and use it in GitHub Desktop.
Save andrewlimaza/1510ac5795edab55c5a21c978e3b3716 to your computer and use it in GitHub Desktop.
Set CVV as a Required Field with PMPro
<?php
/**
* Set CVV as a Required Field with PMPro
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* NOTE: Doesn't yet work with Stripe, Braintree, or PayPal Express (most gateways) that don't pass the CVV to the server.
*/
function my_require_cvv_for_reals( $fields ) {
if ( ! empty( $_REQUEST['CVV'] ) ) {
$CVV = sanitize_text_field( $_REQUEST['CVV'] );
} elseif ( ! empty( $_REQUEST['StripeToken0'] ) ) {
$CVV = true;
} else {
$CVV = '';
}
$fields['CVV'] = $CVV;
return $fields;
}
add_filter( 'pmpro_required_billing_fields', 'my_require_cvv_for_reals', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment