867 
Sometimes, we need to add a new column on the users admin screen sortable. In this blog post you will learn how to add custom column in All users menu in the backend. Here is the code that allows to add custom fields. In this example we would add company name as a custom field. You can also change order of columns. You have to paste this full code in functions.php file.
// This function will also allow you to change order of column
function labotrees_modify_user_table ( $column ) {
$column = array(
"cb" => "",
"username" => "Username",
"name" => "Full Name",
"billing_company" => 'Company Name',
"email" => "E-mail",
"role" => "Role"
);
return $column;
}
add_filter( 'manage_users_columns', 'labotrees_modify_user_table' );
function labotrees_modify_user_table_row ( $val, $column_name, $user_id ) {
switch ($column_name) {
case 'billing_company' :
return get_the_author_meta( 'billing_company', $user_id );
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'labotrees_modify_user_table_row', 10, 3 );
Result:

You Might Be Interested In
- How to remove first occurrence of underscore in a string in javascript?
- How to change Address Format For a Specific Country in Woocommerce?
- WooCommerce: Get Product Info (ID, SKU, $) From $product Object
- Important 2023 Wordpress Developer Interview Questions
- How to Get attributes of product from product ID ?
- How to pass PHP variable to javascript in WordPress?
Post Views: 1,192