69
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 🙂
Snippet (PHP): Show a Custom WooCommerce Column @ WordPress Admin Users Table
/** * @snippet Custom Column @ WordPress Admin Users Table * @how-to Get tutoraspire.com FREE * @sourcecode https://tutoraspire.com/?p=101309 * @author Tutor Aspire * @compatible WooCommerce 3.5.3 * @donate $9 https://tutoraspire.com */ add_filter( 'manage_users_columns', 'tutoraspire_add_new_user_column' ); function tutoraspire_add_new_user_column( $columns ) { $columns['billing_country'] = 'Billing Country'; return $columns; } add_filter( 'manage_users_custom_column', 'tutoraspire_add_new_user_column_content', 10, 3 ); function tutoraspire_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; }