Skip to content
Docs
Get RestroPress

Filter

rpress_valiate_card_format_pre_type

Updated
On this page

Filters the card number validity after the Luhn check and before card type matching.

Runs in rpress_validate_card_number_format() right after the Luhn check. If the value is true, the number then has to match a known card type; if false, validation fails. Use it to add extra checks on the number before type detection.

Parameters#

ParameterTypeDescription
$is_valid_formatboolWhether the number passed the Luhn check.
$numberstringThe card number being validated.

Return value#

bool. Whether the number should continue to card type matching.

Example#

function my_card_format_pre_type( $is_valid_format, $number ) {
	if ( $is_valid_format && 1 === count( array_unique( str_split( $number ) ) ) ) {
		return false;
	}
	return $is_valid_format;
}
add_filter( 'rpress_valiate_card_format_pre_type', 'my_card_format_pre_type', 10, 2 );

Notes#

The hook name is spelled "valiate" in the source and must be used exactly as written.

Source#

Applied in:

  • includes/checkout/functions.php (line 385), in rpress_validate_card_number_format()

See also#

Was this page helpful?