How do I validate extra field (ABN) for whole sale customer
-
I have a custom field (ABN) in my registration form for wholesale customer (Wholesale plugin – Wpexperts) https://amocanailsbeautysupply.com.au/wholesale-login/
To prevent duplicate ABN, (no customers should register the same ABN number in the database) there is control but if I have a custom field I created how can I check it? many thanks
add_filter( 'wpwholesale_registration_errors', 'validate_unique_abn', 10, 2 ); function 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 unique ABN.', 'wpwholesale' ) ); } } return $errors; }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How do I validate extra field (ABN) for whole sale customer’ is closed to new replies.