User ID Column in the Users List
Adds an ID column to the Users screen, which is handy when a plugin or shortcode asks for a user ID.
Opens WPIDE on
Code
add_filter( 'manage_users_columns', function ( $columns ) {
$ordered = array();
foreach ( $columns as $key => $label ) {
$ordered[ $key ] = $label;
if ( 'cb' === $key ) {
$ordered['wpide_user_id'] = 'ID';
}
}
if ( ! isset( $ordered['wpide_user_id'] ) ) {
$ordered['wpide_user_id'] = 'ID';
}
return $ordered;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
return 'wpide_user_id' === $column ? (string) (int) $user_id : $output;
}, 10, 3 );
add_action( 'admin_head-users.php', function () {
echo '<style>.fixed .column-wpide_user_id{width:56px;}</style>';
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.