WooCommerce: Add Column to “Users” Admin Table

On the admin side, you might need to display WooCommerce information inside the users table (WordPress Dashboard > Users). For example, their billing country. Or their phone number. Or maybe some custom calculation e.g. the number of completed orders.

Either way, this is super easy. First, we add a new column – second, we tell what content should go inside it. Enjoy!

Display a custom column @ Users WordPress Dashboard

PHP Snippet 1: Show a Custom WooCommerce Column @ WordPress Admin Users Table (billing country)

/**
 * @snippet       Billing Country @ WordPress Admin Users Table
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @community     https://businessbloomer.com/club/
 */ 

add_filter( 'manage_users_columns', 'bbloomer_add_new_user_column' );

function bbloomer_add_new_user_column( $columns ) {
    $columns['billing_country'] = 'Billing Country';
    return $columns;
}

add_filter( 'manage_users_custom_column', 'bbloomer_add_new_user_column_content', 10, 3 );

function bbloomer_add_new_user_column_content( $content, $column, $user_id ) {

    if ( 'billing_country' === $column ) {
        $customer = new WC_Customer( $user_id );
        $content = $customer->get_billing_country();
    }

    return $content;
}

PHP Snippet 2: Show a Custom WooCommerce Column @ WordPress Admin Users Table (billing phone)

/**
 * @snippet       Billing Phone @ WordPress Admin Users Table
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @community     https://businessbloomer.com/club/
 */ 

add_filter( 'manage_users_columns', 'bbloomer_add_new_user_column' );

function bbloomer_add_new_user_column( $columns ) {
    $columns['billing_phone'] = 'Phone';
    return $columns;
}

add_filter( 'manage_users_custom_column', 'bbloomer_add_new_user_column_content', 10, 3 );

function bbloomer_add_new_user_column_content( $content, $column, $user_id ) {

    if ( 'billing_phone' === $column ) {
        $customer = new WC_Customer( $user_id );
        $content = $customer->get_billing_phone();
    }

    return $content;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • WooCommerce: Add Column to Orders Table @ WP Dashboard
    The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one. […]
  • WooCommerce: Display Custom Filters @ WP Dashboard > Products
    If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily? For example, you could add “Filter by product tag” (“product […]
  • WooCommerce: Hide/Show The WP Admin Bar
    In previous WooCommerce versions, new customers could access the WP Admin black bar after purchase. Now this seems fixed. Still, what about other user roles, and what if you want to override this default behavior? Well, here’s a quick snippet for you – feel free to use it in your own WooCommerce site. Enjoy!
  • WooCommerce: Calculate Sales by State
    You’re filing your tax returns and need to know how much you earned in each state… but then find out WooCommerce doesn’t give you this calculation by default within its reports! Don’t worry – today I’ll share a quick snippet so that you can calculate the amount you need in a second. Feel free to […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

15 thoughts on “WooCommerce: Add Column to “Users” Admin Table

  1. I have written simple code to show Order Count for customer:

      $content =wc_get_customer_order_count ($user_id);

    How can I make this column sortable?

  2. Hey,
    great snippet.
    But Iยดm facing a little issue with that. Im trying to insert the column for number of completet orders, but Im not able to find the right column. Billing_country and for example address are working fine. Any chance to tell me what column I need to define?

    Cheers

    1. You can rename “billing_country” to whatever you like in the snippet, the important part is what you will do with the $customer variable. You will need to “read” all customer orders from there

  3. The best woocoommerce page/tips! Thansk a lot!

    Can I add a column indicating that the purchase made was the customer’s first purchase?

    Thanks for helping the community

    1. Hey Jorge, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Hey Rodolfo, this was a super helpful script. Was able to tweak it to show the Last Order date instead and had a question. Is there a way to make the new WC_Customer column sortable? Attempts to sort by the order date sorts by the username instead. Any ideas?

    1. Jen, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Very useful snippet! Hey Rodolfo, could you please tell how to do it for multiple columns? Need to repeat the code or is there any efficient way? TIA

    1. No need to create a new function, just add a new column:

      $columns['billing_country'] = 'Billing Country';
      $columns['new_col'] = 'New Col';
      
      1. Hi there
        If I have to add billing country and billing_city, for example, how can I write the code?
        I have added this

        add_filter( 'manage_users_columns', 'bbloomer_add_new_user_column' );
          
        function bbloomer_add_new_user_column( $columns ) {
            $columns['billing_company'] = 'Ragione Sociale';
        $columns['billing_city'] = 'New Col';
            return $columns;
        }
          
        add_filter( 'manage_users_custom_column', 'bbloomer_add_new_user_column_content', 10, 3 );
          
        function bbloomer_add_new_user_column_content( $content, $column, $user_id ) {
            
            if ( 'billing_company' === $column ) {
           $customer = new WC_Customer( $user_id );
                $content = $customer->get_billing_company();
            }
            
            
            if ( 'billing_city' === $column ) {
           $customer = new WC_Customer( $user_id );
                $content = $customer->get_billing_city();
            }
            return $content;
        }
        

        Is it correct?
        Best regards

        1. The code above works, but if I want to add a custom field (billing_wooccm16 that is a select type field with option of dropdown menu) and I write so

          add_filter( 'manage_users_columns', 'bbloomer_add_new_user_column' );
             
          function bbloomer_add_new_user_column( $columns ) {
              $columns['billing_company'] = 'Ragione Sociale';
          $columns['billing_wooccm16'] = 'New Col';
              return $columns;
          }
             
          add_filter( 'manage_users_custom_column', 'bbloomer_add_new_user_column_content', 10, 3 );
             
          function bbloomer_add_new_user_column_content( $content, $column, $user_id ) {
               
              if ( 'billing_company' === $column ) {
             $customer = new WC_Customer( $user_id );
                  $content = $customer->get_billing_company();
              }
               
               
              if ( 'billing_wooccm16' === $column ) {
             $customer = new WC_Customer( $user_id );
                  $content = $customer->get_billing_wooccm16();
              }
              return $content;
          }
           

          This code doesn’t work

          1. $customer->get_billing…. is used by WooCommerce to get WooCommerce fields, so that won’t work with a custom field. You should study the documentation of the plugin you used to add the custom field, and see how to retrieve it – that will give you the correct code to use. Hope this helps!

  6. Please help me Can add columns the day users create an account ? Thanks.

    1. Hello Kinh, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *