Last Edited By Column
Shows who last edited each post or page, and when, in the admin lists. Useful when several people work on the same content.
Opens WPIDE on
Code
// Post types that get the column.
$wpide_last_editor_types = array( 'post', 'page' );
foreach ( $wpide_last_editor_types as $wpide_editor_type ) {
add_filter( "manage_{$wpide_editor_type}_posts_columns", function ( $columns ) {
$columns['wpide_last_editor'] = 'Last edited by';
return $columns;
} );
add_action( "manage_{$wpide_editor_type}_posts_custom_column", function ( $column, $post_id ) {
if ( 'wpide_last_editor' !== $column ) {
return;
}
$editor_id = (int) get_post_meta( $post_id, '_edit_last', true );
$editor = $editor_id ? get_userdata( $editor_id ) : false;
echo $editor ? esc_html( $editor->display_name ) : '—';
echo '<br><small>' . esc_html( get_post_modified_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), false, $post_id, true ) ) . '</small>';
}, 10, 2 );
}
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.