Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Hotel Booking Custom list of Booking on email
- This topic has 3 replies, 2 voices, and was last updated 3 weeks ago by
J. Davis.
- AuthorPosts
- September 24, 2025 at 9:23 am #1796653
Floris Stam
ParticipantHi All,
Question, I try to list all the bookings outside the standard shortcode, so in my userdashboard I want to show the bookings connected to my user.
function custom_mphb_bookings_from_postmeta() {
if (!is_user_logged_in()) {
return ‘<p>Please log in to view your bookings.</p>’;
}$user_email = strtolower(trim(wp_get_current_user()->user_email));
$args = array(
‘post_type’ => ‘mphb_booking’,
‘post_status’ => ‘any’,
‘posts_per_page’ => -1,
‘meta_query’ => array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘_mphb_email’,
‘value’ => $user_email,
‘compare’ => ‘=’
),
array(
‘key’ => ‘_mphb_customer_email’,
‘value’ => $user_email,
‘compare’ => ‘=’
)
)
);$query = new WP_Query($args);
$output = ”;if ($query->have_posts()) {
$output .= ‘<div class=”user-bookings”>’;
while ($query->have_posts()) {
$query->the_post();
$booking_id = get_the_ID();
$check_in = get_post_meta($booking_id, ‘_mphb_check_in_date’, true);
$check_out = get_post_meta($booking_id, ‘_mphb_check_out_date’, true);
$status = get_post_meta($booking_id, ‘_mphb_booking_status’, true);
$room_type_id = get_post_meta($booking_id, ‘_mphb_room_type_id’, true);
$room_title = get_the_title($room_type_id);$output .= ‘<div class=”booking-card”>’;
$output .= ‘<h4>Booking #’ . esc_html($booking_id) . ‘</h4>’;
$output .= ‘<p>Accommodation: ‘ . esc_html($room_title) . ‘</p>’;
$output .= ‘<p>Check-in: ‘ . esc_html($check_in) . ‘</p>’;
$output .= ‘<p>Check-out: ‘ . esc_html($check_out) . ‘</p>’;
$output .= ‘<p>Status: ‘ . esc_html(ucfirst($status)) . ‘</p>’;
$output .= ‘</div>’;
}
$output .= ‘</div>’;
wp_reset_postdata();
} else {
$output .= ‘<p>No bookings found for ‘ . esc_html($user_email) . ‘.</p>’;
}return $output;
}
add_shortcode(‘custom_user_bookings’, ‘custom_mphb_bookings_from_postmeta’);But every time it don’t give me bookings back, is it possible what I want?
September 25, 2025 at 7:49 am #1796769J. Davis
KeymasterHi, our team does not provide consultations, guidance, or support related to code modifications or customizations. Our support is limited to the standard features and functionality of the product as delivered.
For questions or issues regarding the product’s intended use, please continue to reach out through the forum, and we will be glad to assist. However, any requests involving alterations to the code or custom implementations fall outside the scope of our support services.
Thank you for your understanding and cooperation.
September 25, 2025 at 8:50 am #1796791Floris Stam
ParticipantThanks for your reply. Clear.
Is this something for the extended support?
What I want is a list of bookings based on user, but not via the shortcode of the standard.September 26, 2025 at 12:16 pm #1797054J. Davis
KeymasterHi Floris, unfortunately, we do not provide customization services or guidance of this type at all. You may feel free to customize the plugin on your own or with the help of third-party developers.
- AuthorPosts
- You must be logged in to reply to this topic.