• Resolved tothanhtuan

    (@tothanhtuan)


    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;
    }
    • This topic was modified 1 year, 9 months ago by tothanhtuan.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • HI @tothanhtuan,

    Thanks for contacting us,

    I hope you are doing well, You are using the PRO version of our plugin so kindly open a support ticket via our website as we are not allowed to provide support on paid versions through this platform.

    Thanks & Regards

    WP Experts Support Team

Viewing 1 replies (of 1 total)
  • The topic ‘How do I validate extra field (ABN) for whole sale customer’ is closed to new replies.