WooCommerce: Add Column to Users Dashboard 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 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

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

/**
 * @snippet       Custom Column @ WordPress Admin Users Table
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=101309
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */ 

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;
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

13 thoughts on “WooCommerce: Add Column to Users Dashboard Table

  1. 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

  2. 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!

  3. 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!

  4. 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!

  5. 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? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.