Home / Archive / Booking Plugin with ChatGPT
Duplicate Snippet

Embed Snippet on Your Site

Booking Plugin with ChatGPT

Create WordPress plugin with chatgpt free [Step-by-Step Tutorial]
https://maxkinon.com/create-wordpress-plugin-with-chatgpt-free-step-by-step-tutorial/

Code Preview
php
<?php
<?php
/**
 * Plugin Name: Book Me Now
 * Description: A WordPress booking plugin that allows customers to book meetings and sends confirmation emails.
 * Version: 1.0
 * Author: Your Name
 */
// Register a shortcode for the booking page
function book_me_now_shortcode() {
    ob_start();
    // Display the booking form here
    ?>
    <form method="post" action="">
        <label for="customer_name">Your Name:</label>
        <input type="text" id="customer_name" name="customer_name" required><br><br>
        <label for="customer_email">Your Email:</label>
        <input type="email" id="customer_email" name="customer_email" required><br><br>
        <label for="meeting_date">Meeting Date:</label>
        <input type="date" id="meeting_date" name="meeting_date" required><br><br>
        <input type="submit" name="book_now" value="Book Now">
    </form>
    <?php
    $content = ob_get_clean();
    return $content;
}
add_shortcode('book-me-now', 'book_me_now_shortcode');
// Handle form submission
function book_me_now_handle_form() {
    if (isset($_POST['book_now'])) {
        $customer_name = sanitize_text_field($_POST['customer_name']);
        $customer_email = sanitize_email($_POST['customer_email']);
        $meeting_date = sanitize_text_field($_POST['meeting_date']);
        // Validate and process booking here
        // You can store the booking information in your database and send confirmation email
        
        // Send confirmation email
        $to = $customer_email;
        $subject = 'Meeting Confirmation';
        $message = "Hello $customer_name,\n\n";
        $message .= "Your meeting on $meeting_date has been booked successfully.\n";
        $headers = 'From: Your Name <[email protected]>' . "\r\n";
        wp_mail($to, $subject, $message, $headers);
        // Redirect or display a success message
    }
}
add_action('init', 'book_me_now_handle_form');
?>

Comments

Add a Comment