Skip to content

Instantly share code, notes, and snippets.

@leavlzi
Created June 27, 2017 17:05
Show Gist options
  • Save leavlzi/828f967459163d2b45c4d0df20ec1d85 to your computer and use it in GitHub Desktop.
Save leavlzi/828f967459163d2b45c4d0df20ec1d85 to your computer and use it in GitHub Desktop.
Add the User ID column to the WordPress Users Table
/*
copy the following code to you current theme functions.php file:
*/
/*
* Adding the column
*/
function rd_user_id_column( $columns ) {
$columns['user_id'] = 'ID';
return $columns;
}
add_filter('manage_users_columns', 'rd_user_id_column');
/*
* Column content
*/
function rd_user_id_column_content($value, $column_name, $user_id) {
if ( 'user_id' == $column_name )
return $user_id;
return $value;
}
add_action('manage_users_custom_column', 'rd_user_id_column_content', 10, 3);
/*
* Column style (you can skip this if you want)
*/
function rd_user_id_column_style(){
echo '<style>.column-user_id{width: 5%}</style>';
}
add_action('admin_head-users.php', 'rd_user_id_column_style');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment