I’ve a customized subject (ABN) in my registration kind for wholesale buyer (Wholesale plugin – Wpexperts)
https://amocanailsbeautysupply.com.au/wholesale-login/
To stop duplicate ABN, (no clients ought to register the identical ABN quantity within the database) there’s management but when I’ve a customized subject I created how can I verify it? many thanks
add_filter( 'wpwholesale_registration_errors', 'validate_unique_abn', 10, 2 );
perform validate_unique_abn( $errors, $sanitized_user_login ) {
if ( isset( $_POST['abn'] ) && ! empty( $_POST['abn'] ) ) {
$abn = sanitize_text_field( $_POST['abn'] );
$existing_user = get_users( array(
'meta_key' => 'abn',
'meta_value' => $abn,
'fields' => 'ID',
) );
if ( ! empty( $existing_user ) ) {
$errors->add( 'abn_error', __( 'This ABN is already registered. Please enter a novel ABN.', 'wpwholesale' ) );
}
}
return $errors;
}