• Resolved BeyondLine

    (@beyondline)


    Hi,
    i’m trying to add a simple button (X) below the checkbox of each row in order to delete easily one specific booking. When i try something like this :

    <form action method=”post”><button type=”submit” name=”action” value=”delete”>X</button></form>

    it seems to work because the success message appears on top but obviously something is missing to link this form with the booking id. Could you help me ?

    Thanks a lot for this plugin,
    Olivier.

    https://wordpress.org/plugins/restaurant-reservations/

Viewing 1 replies (of 1 total)
  • Hi Olivier,

    You won’t be able to add a form into the table because the whole thing is already wrapped in a form. That’s how the bulk actions are processed.

    You could try to hijack the bulk actions process using a link like this:

    <?php
    
    /* Replace the * below with the Booking ID */
    echo admin_url( 'admin.php?page=rtb-bookings&action=delete&bookings=*' );
    
    ?>

    However, this won’t work right out of the gate because the process_bulk_actions() method only looks in $_POST, not $_GET.

    For that reason, you’d need to hook into rtb_bookings_table_bulk_action to process the deletion.

    I can’t guarantee that will be super future-proof, to be honest. If you’re going to that much trouble, I’d recommend you just hook into current_screen and process the deletion yourself with your own link. The $rtb_controller global should be available then so you can just call $rtb_controller->cpts->delete_booking( $id ) to remove the booking (after validating the user, of course!).

Viewing 1 replies (of 1 total)

The topic ‘Add delete button into the booking table’ is closed to new replies.