Okay
  Public Ticket #3731243
Block auto fill username field during adding a new client
Closed

Comments

  •  2
    Lukasz started the conversation

    Hi, During adding new customer in chrome browser there is username and password field filled automatically. Is there any simple way to block it?

    It is possible for the username and password to be generated automatically, e.g. based on the email address or name and surname. and remove this field.

    Why agent has come up with the password? It should be generate automatically (agent shouldn't know it)


    Attached files:  Zrzut ekranu 2024-09-24 o 14.15.10.png

  •  2,212
    WebWizards replied

    Hi,

    It is possible to remove the username and password field, and have them generated automatically.

    To do this, add the following PHP snippet to your site:

    add_action('salesking_dashboard_head', function(){
        ?>
        <script>
            jQuery(document).ready(function(){
                jQuery('#salesking_add_customer_form #username').parent().parent().remove();
                jQuery('#salesking_add_customer_form #password').parent().parent().remove();
            });
        </script>
        <?php
    });
    add_filter('salesking_filter_newcustomer_username', function($user){
        return sanitize_text_field($_POST['emailaddress']);
    }, 10, 1);
    add_filter('salesking_filter_newcustomer_password', function($password){
        return wp_generate_password();
    }, 10, 1);

     

    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/

     

    It will then show only an email field and generated the rest automatically.

     

    Kind regards,

    Stefan

  •  2
    Lukasz replied

    Works perfectly! Thank You