• Resolved realexpander

    (@realexpander)


    Dear EME developers,

    for a website I needed an EME hook which is called when a booking order is approved. I’ve looked into the documentation and into the EME source code and found that there is no such hook. (Please correct me if I’m wrong.)

    Since having such an approval hook was crucial for my website, I created one myself. This was extremely easy to do, mainly because the EME source code is very readable and well structured. Here I’d like to share my changes.

    I simply added the following few lines to the end of the function eme_approve_booking() in the file eme_rsvp.php:

    
    if (has_action('eme_approve_rsvp_action')) {
        $booking = eme_get_booking($booking_id);
        do_action('eme_approve_rsvp_action', $booking);
    }
    

    The hook introduced in this way I called eme_approve_rsvp_action. It can be used by calling add_action() in the usual way:

    
    add_action('eme_approve_rsvp_action', 'my_approval_hook');
    

    Since it would be cumbersome to add the lines from above each time EME gets updated and eme_rsvp.php is overwritten, I’d like to propose to put this new hook into the official EME package (maybe including a brief hint in the documentation). In this way it can be used by others (and myself) in the future without modifying the EME source code.

    Many thanks in advance,
    Alexander Voigt

    P.S.: Please feel free to adapt/change/discard my code as you like! I can also provide further help, for example by providing the change in form of a patch or so.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Franky

    (@liedekef)

    Thanks for the contribution. I took a look at the code, and your action hook would get executed before the booking is approved. I guess you’d want it *after* approval, and that can be done in the function eme_ajax_action_rsvp_aprove, after the call to eme_approve_booking(), in the “if ($res) {” part below that call:

    
             if ($res) {
                     if (has_action('eme_approve_rsvp_action')) {
                         do_action('eme_approve_rsvp_action', $booking);
                     }
                     if ($send_mail) {
                             $res2 = eme_email_rsvp_booking($booking,$action,0,$queue);
                             if (!$res2) $mails_ok=0;
                     }
             } else {
                     $action_ok=0;
             }
    

    That I can add ??

    Thread Starter realexpander

    (@realexpander)

    Dear Franky,

    many thanks for the hint, that would in deed be better! ??
    Many thanks for considering this change!

    Best regards,
    Alexander Voigt

    Plugin Author Franky

    (@liedekef)

    Added in trunk ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Feature proposal: Hook for approval’ is closed to new replies.