567
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 open Elementor popup using Wordpress Ajax?
- Custom redirect on clicking add to cart in WooCommerce
- How to change text on addition notes in woo-commerce ?
- What is the difference between add_filter and apply_filters?
- How to run jQuery after WooCommerce AJAX cart updated?
- Top 8 best WordPress Page Builders
Post Views: 879