Posted: August 31, 2020 at 1:49 pm
Greetings – EE4: After I select the “Submit” button on the registration form for an event IF there are no errors I would like to skip the Registration Confirmation page completely, and redirect to another URL right away. I already have plugin with a function written to extend the Submit functionality: function my_custom_submit_action( $spco, $data) // No errors – redirect to the TRACOM Learning website URL But the Registration Confirmation page is still displaying the redirect is not working. Can you help me out with the right way to do this with EE4? Thanks, Mark |
|
Hi Mark, That filter will be ‘fired’ on an ajax request and not the page you are viewing, meaning you won’t see the redirect with the above. Take a look at how the attendee information reg step does pretty much exactly what you are trying to do HERE.
|
|
Tony – I am not sure I am following you. I looked at the code snippet. So are you saying that I need to add the code from line numbers 1462 to 1470 to my custom action, or do I need to create a new action/filter for this? I’m a little confused. Also I just purchased a priority support token. If I use it for this can I get more in-depth (detailed) help or how does that work? Finally, just curious is Josh no longer on your support staff? Thanks, Mark |
|
My apologies, with you extending the above to add your own functionality I assumed you could follow this with minimal details and just needed a nudge in the right direction. This hook That hook is fired at the end of the So, this:
Can’t be used on the ajax request as it redirects the ajax request, not the user. Instead if we follow what
SPCO will handle the redirect for you and do what you are trying to do. However, this:
Is going to prevent that from running, if the response is true you’ve already returned before you redirect, so you should use something like:
Generally, we don’t provide the above level of support for customizations, as we can not support/review your custom code. With a support token we can (if possible within the timeframe ) provide you with a working snippet and explanation like that above. Its a judgement call in that if you purchase a support token and ask use to completely rewrite X functionality or create a custom some custom output for you etc then we will likely refuse as it simply isn’t viable on both sides to use support tokens. But if you need us to walk fix X and or explain Y we are happy to do so as long as it relates to Event Espresso.
Yes, Josh is still a member of the team 🙂 |
|
So if I swap my line: header(“Location: https://tracomlearning.com/“); So for the code that you recommended I need to get a single page checkout object $spco somehow don’t I? $checkout = EE_Registry::instance()->SSN->checkout(); One more thing: If my web service call results in an error I need to display the error. Normally I would just display it on the Registration Confirmation page, but now I am eliminating that page so I was thinking just use a popup message instead. I tried the easy PHP way to do this: Tony – I know some basic PHP but in the past Josh has helped out with a TON with the custom PHP coding I have needed to do in EE. That’s why I asked about him earlier. Thanks for all of your help and going deeper with your explanation… Mark |
|
Yes, and you already have all you need.
Did you try using the code I gave you above in your function and then test a registration? This:
That gets you an instance of EE_Checkout from the current session, the code above uses the EE_Checkout from within SPCO, you need to use the above for what you are trying to do.
Yeah, that’s not going to work because if you’re using the above its firing on a separate request (the Ajax request in the background). You could use Have you had a looked into how the
I’m not sure how to reply to this without it coming across the wrong way but if you prefer to wait for Josh I can ask him to take a look at this thread when he has some time. However, I’m not really sure what additional information he can give you without doing it for you as everything you need to do what you have requested is already in this thread. |
|
Tony – Sorry for that last post in that I didn’t realize my action already had the $spco as an input argument. I just overlooked it. I’m more tired than I thought I guess. And by my last comment I only meant that the reason it might have appeared that I am more knowledgable about EE than I really am is that I have received a lot of help from Josh in the past to get most of my code setup. I didn’t do it myself. I wasn’t implying that I wanted him now for this. You have been really helpful and I really appreciate it – I’m trying all this code out now… |
|
So I tried this new code out. The good news is a redirect is occurring. The bad news is it is redirecting to my WordPress Admin login page and not to the tracomlearning.com page. I tried http, https, various different flavors of that URL, and I tried just google.com. I keep going to this URL: I debugged the checkout object and it looks like the right values are being set in the object itself so I am not sure why it’s going to this other URL. Is there a default redirect URL that is set at some point in EE, maybe in the settings? Thanks for your help – Mark |
|
Actually it is using wp_safe_redirect() so you’ll likely need to whitelist that domain for it to work, you can do that using a snippet like this: https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts And you would have something like:
|
|
Tony – Thanks for the redirect information. Now the redirect is working great. Also thanks for the error related information. I put that code into place but really strange things were happening. Long story short I found out that my theme is conflicting with EE in some places. When I switched to the standard 2019 WordPress theme everything worked exactly like it should. So I have some work to do on the theme to see why it is conflicting with Event Expresso on form and error processing. THANK YOU VERY MUCH for all your help – I really appreciate it! Mark |
|
You’re most welcome. I’m guessing the conflict is based around the espresso-notices and/or espresso-ajax-notices? |
|
September 10, 2020 at 12:58 pm I spoke too soon – I still have a redirect issue, let me show you… On the Register Form fill in the first 4 fields with whatever (make sure the 2 email addresses match). On the Access Code field enter “Test”. Check the box and select the Submit Registration button. SO if that Access Code had been valid then EE would go straight to the redirect like it’s supposed to. But this Access Code is invalid so it will throw an error. Dismiss the error box and change the Access Code to “EYAccessCode” which IS valid. Select the Submit Registration button again. Now EE displays the Thank You page instead of going to the redirect URL, which I don’t want. So throwing that error is causing some condition to be set in EE so that it behaves differently on the next submit. Do you have any idea how to resolve this so that it correctly goes to the redirect URL instead? Thanks again in advance – Mark |
|
Tony – I should have also mentioned that in my PHP code once I determine that the Access Codes do NOT match I throw an error using the statement that you suggested further up in this posting: EE_Error::add_error(esc_html__($error, ‘event_espresso’), __FILE__, __FUNCTION__, __LINE__ ); Hope that helps with this… Thanks, Mark |
|
Hi Mark, Just noting here for future readers that this issue was resolved via email and a new filter will be added to Event Espresso which allows you to hook in before the reg step is processed and prevent the registration. The issue above is happening because the current hook runs after the registration has been processed and all of the registration questions have been saved etc. The submission is halted and then resubmitted with the correct code, but now EE knows there are registration answers and its trying to compare the form with the saved values (which is should be doing) and things get confused. Adding a new hook into this allows you to hook and stop the process before that happens, throw an error and only submit when it actually should do. |
|
The support post ‘Skip Registration Confirmation Page and Redirect to URL instead’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.