Hello,
I am using Rentalhive and I want to display the host’s name that corresponds to the booking request in a column of the booking table. I entered the following code, but the mention “No Host Assigned” appears. Which part of the code should I modify to see the host’s name appear (as a link to their account, like in the “order” table)?
// Ajouter une colonne personnalisée "Hôte" dans le tableau des réservations
add_filter('manage_edit-hp_booking_columns', 'add_booking_host_column');
function add_booking_host_column($columns) {
// Insérer une nouvelle colonne "Hôte" après la colonne "title"
$new_columns = [];
foreach ($columns as $key => $value) {
$new_columns[$key] = $value;
// Ajouter la colonne "Hôte" après la colonne "Title"
if ($key == 'title') {
$new_columns['vendor'] = __('Host', 'text_domain');
}
}
return $new_columns;
}
// Remplir la colonne "Hôte" avec le nom de l'hôte correspondant
add_action('manage_hp_booking_posts_custom_column', 'fill_booking_host_column', 10, 2);
function fill_booking_host_column($column, $post_id) {
if ($column === 'vendor') {
// Récupérer l'ID de l'hôte (host) lié à cette réservation
$host_id = get_post_meta($post_id, 'vendor', true); // Assure-toi que '_hp_vendor_id' est la bonne clé pour l'hôte
if ($host_id) {
// Récupérer les informations de l'utilisateur (l'hôte)
$host = get_userdata($host_id);
if ($host) {
// Afficher le nom d'utilisateur de l'hôte
echo esc_html($host->user_login); // Tu peux aussi utiliser $host->display_name si tu préfères afficher le nom complet
} else {
echo __('Unknown', 'text_domain');
}
} else {
echo __('No Host Assigned', 'text_domain');
}
}
}