phpcsswordpresswoocommercefield

Hide WooCommerce billing and shipping fields in WordPress user profile


I can't find an easy way to hide some WooCommerce billing and shipping fields that are visible in the user profile in the backend of WordPress.

For instance I want to hide billing_address_2 and shipping_address_2 in the WordPress user profile. Is there a good way to do that with a code snippet? I tried hiding the sixt row in css with the code below, but I can't get that to work either.

#fieldset-billing.form-table tr:nth-child(6) {
     display: none;
}

How can I hide WooCommerce billing and shipping fields in WordPress user profile?


Solution

  • To hide billing and shipping address2 fields from WordPress Backend User profile try this:

    add_action('admin_head', 'custom_admin_user_styles');
    function custom_admin_user_styles() {
        ?>
        <style>
            table#fieldset-billing tr:nth-child(5),
            table#fieldset-shipping tr:nth-child(6){
                display: none !important;
            }
        </style>';
        <?php
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and work.