Redirect after submission

This topic contains 6 replies, has 2 voices, and was last updated by  Veronika Nesverova 6 years, 8 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28084

    Hello.

    I tried to setup different redirect after someone signs up.
    Following https://wp-event-organiser.com/forums/topic/dedicated-bookings-landingpage-possible/ I tried to do it as:

    function workshoppa_redirect_after_booking($booking_id, $booking, &$errors, $form) {
        $total_price = eo_get_booking_meta($booking_id, 'booking_amount');
        $event_id = eo_get_booking_meta($booking_id, 'event_id');
    
        if (0 == $total_price) {
            eo_confirm_booking($booking_id, true);
        }
    
         // Set redirect url and send them there
         $redirect = '/signup/'.get_permalink($event_id);
         wp_redirect($redirect);
         exit();
     }
    
    //This will work only for gateways where you don't leave the site.
    add_filter('eventorganiser_pre_gateway_booking_stripe', 'workshoppa_redirect_after_booking', 100, 4);
    add_filter('eventorganiser_pre_gateway_booking_free', 'workshoppa_redirect_after_booking', 100, 4);
    add_filter('eventorganiser_pre_gateway_booking_offline', 'workshoppa_redirect_after_booking', 100, 4);
    

    But I cannot notice any difference when trying to redirect.

    I also tried to redirect to another string as well, but to no effect.

    Any clues?

    Veronika Nesverova
    #28113

    Hi,

    Sorry for the delay in getting back to you. The redirect url is incorrect. get_permalink($event_id); will return something like http://yoursite.com/events/event/my-event.

    So you’re trying to redirect them to

    /signup/http://yoursite.com/events/event/my-event
    

    Also, and this wasn’t causing the issue, but the & before $errors on the first line was giving me a warning – this is something that may have changed since the original post.

    Stephen Harris
    #28114

    Thank you for your response!

    Where did you catch the error with the &?
    Not sure how to debug such a thing.

    I’ll look into it and then I can probably figure out the redirect path as well.

    Cheers!

    Veronika Nesverova
    #28143

    I had error reporting turned on, so the warning appeared on the screen. (see for instance: http://php.net/manual/en/function.error-reporting.php ).

    It’s just a warning, so it’s likely to be suppressed on your server. You would generally only have error reporting enabled on a non-production server.

    Stephen Harris
    #28150

    Thank you, I got the error reporting setup – but do not receive an error on the §$error variable.

    However, I can only get this method to run when the payment is not successful or is pending.

    When the payment is confirmed directly – it is still redirected to /events.

    I found the slug by doing:

        $slug = get_post($event_id)->post_name;
        $redirect = '/signup/' . $slug;
    

    And I do not get any errors.
    Does this filter on each submission? What does it mean that it is pre gateway?

    Veronika Nesverova
    #28161

    The redirect will need to be a URL not a slug.

    You might not get warnings with the &$errors depending on your PHP version, but in any case, this isn’t causing the problem here.

    pre_gateway here means before the user is redirected to the gateway. It’s a bit of misnomer because most gateways (with the exception of PayPal and ‘offline’) use that hook to process the booking with the gateway (and this may or may not involve redirecting them off-site), and then redirect them to a confirmation page.

    Unfortunately, it does its not possible to alter the confirmation page for the stripe gateway. I can release an update to try help rectify that.

    For the offline / free gateways the above code should work.

    Stephen Harris
    #28165

    The redirect worked most of the time, but could change it to an url.

    Would be really useful if you could update the Stripe-gateway!

    Thank you for your support.

    Veronika Nesverova
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.