how to add updated_by column to posts admin panel?

You’ll want to use the manage_{$post_type}_posts_columns filter and the manage_{$post_type}_posts_custom_column action:



  function wp2342412_add_updated_by_column( $columns ) {
    // Ensure your column isn't already set.
    if ( isset( $columns['updated_by'] ) ) {
        return $columns;
    }

    // Add your column to the end of the columns definition:
    $columns['updated_by'] = __( 'Updated By', 'your-text-domain' );
    return $columns;

    /**
      * If you want to insert your column elsewhere, it's a bit more involved.
      *
      * This example will insert the column after the Author column.
      * N.B.: You'll need to remove lines 20 and 21 to get here!
      */

    // Find the index of the author column, and add 1 to put our column *after* it.
    $author_idx    = array_search( 'author', array_keys( $columns ) ) + 1;
    $beginning     = array_slice( $columns, 0, $author_idx, true );
    $custom_column = [ 'updated_by' => __( 'Updated By', 'your-text-domain' ) ];
    $ending        = array_slice( $columns, $author_idx, NULL, true );

    $columns = $beginning + $custom_column + $ending;

    return $columns;
 }

add_filter( 'manage_post_posts_columns', 'wp2342412_add_updated_by_column', 10 );

function wp432523_populate_updated_by_column( $column_name, $post_id ) {
    // Ensure we only operate on our custom column.
    if ( 'updated_by' !== $column_name ) {
        return;
    }

    echo esc_html( get_the_modified_author( $post_id ) );
    return;
    // Or, comment out the above two lines (39 and 40) and get *fancy*
    $post = get_post( $post_id );
    $url  = add_query_arg( [
        'post_type' => $post->post_type,
        'author'    => $post->_edit_last ?: $post->post_author,
    ] );

    echo sprintf( '<a href="https://wordpress.stackexchange.com/questions/327459/%1$s">%2$s</a>', $url, get_the_modified_author( $post_id ) );
}

add_action( 'manage_post_posts_custom_column', 'wp432523_populate_updated_by_column', 10, 2 );