Show vendor column for bookings

Hello, I would like to add the column “host” (provider of the accommodation) in my booking page because we have: account, date, ad title, and it suits me to have the column host to contact them directly without going through 10 steps: I made the following code, I have the column that is displayed, but it shows me the id of the account (customer) and not the host who added the ad: can you tell me what is wrong :

// Ajouter une colonne "Hôte" à la page des réservations
function custom_booking_columns( $columns ) {
    $columns['hp_vendor'] = __( 'Hôte', 'text-domain' );
    return $columns;
}
add_filter( 'manage_edit-hp_booking_columns', 'custom_booking_columns' );

// Afficher le nom de l'hôte qui a fourni le bien dans la colonne "Hôte"
function custom_booking_column_content( $column, $post_id ) {
    if ( 'hp_vendor' === $column ) {
        $hote_id = get_post_meta( $post_id, 'hp_vendor', true );
        $hote_name = get_the_author_meta( 'display_name', $hote_id );
        echo esc_html( $hote_name );
    }
}
add_action( 'manage_hp_booking_posts_custom_column', 'custom_booking_column_content', 10, 2 );

Vendor is a custom post type, not a user, so you can try get_post_title instead of get_the_author_meta instead.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.