Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active February 15, 2019 13:26
Show Gist options
  • Save ideadude/6a83e187d5285fb29a992c78853ed22b to your computer and use it in GitHub Desktop.
Save ideadude/6a83e187d5285fb29a992c78853ed22b to your computer and use it in GitHub Desktop.
Set CVV as a Required Field with PMPro
/**
* 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 all gateways.
* You'll need to make sure the gateway is set to require CVV/CVC
* and then add an elseif ( ... ) below to set the $CVV var
* if you see a valid gateway token/etc.
*/
function my_require_cvv_for_reals( $fields ) {
if ( ! empty( $_REQUEST['CVV'] ) ) {
$CVV = sanitize_text_field( $_REQUEST['CVV'] );
} elseif ( ! empty( $_REQUEST['stripeToken0'] ) ) {
// Stripe. Make sure you set the Radar rule to require CVC check.
$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