Posted: May 26, 2020 at 9:02 pm
Greetings – I am using my own filter function to customize the message that is displayed upon registration success. I added my filter like this (on a tip that Josh gave me a few months ago):
The problem is that the $event object appears to be empty when I make these EE calls to get the information I need. When I use this same code earlier in the registration process it works. When I call it for this filter it doesn’t. Do the EE objects go away or get wiped out at some point in the registration processing? Any ideas why $event is no longer valid? Appreciate any help!!! |
|
Hi there,
You’ll likely find the problem isn’t The reason being is the code above uses the current session and pulls the checkout object from that, then pulls the transaction from checkout and so on. On the thank you page, the registration(s) has been finalized and the session closed, so The reason it works prior to the thank you page is due to the session being open (which it needs to be for the registrations to work). From the above, your hooking into the order description to output just an ID, is that visible? The reason I ask is your code is using SSN to the EE_Transaction object related to the request, but there are multiple other hooks on the thank you page that are already passed the current EE_Transaction object, for example:
They obviously don’t fire for the order confirmation description but could you not use one of those for what you are trying to do? If not, it is possible to pull the EE_Transaction object from the values passed in the query string when the thank you page is loaded for a specific registration and we have some details on how here: |
|
Tony – My goal is to change the thank you message that is displayed by default on the reg. confirmation page. Josh told me a while back that I had to tie into that EE/WP hook to be able to do that. Let me back up a little… We have EE events created in WordPress for each different type of training that we offer. Each type of training is associated with an ID. That ID is entered as part of creating each event in EE. We add it as an extra field for the event. $externalSessionType = get_post_meta($event->ID(), ‘max_session_type_id’, true); So I need the EE event object in order to get at that extra ID. As you stated if the transaction is longer there in that WP hook I can’t get at EE event object. Is there another way to get that ID that would work within that hook filter method? FYI – I also tried using a global variable to solve this. So earlier on I get the ID using the code above then stored it in a PHP global variable, thinking it would be there when I need it. But that didn’t work either. When I go to access the global variable in my hook filter method it is gone. Not sure why. Is there any other way to change the confirmation page thank you message that you can think of? That’s all I need to be able to do… Thanks in advance – Mark |
|
Ok, so you need to do it within the filter hook you mentioned then and yes there is a method to do just that included in the documentation link I gave you earlier: You’d basically be replacing the first 5 lines of your
You also don’t need to loop over all registrations from the transaction (I know you break the loop) but you can just use
If I understand correctly, that global variable wouldn’t be set on the thank you page request as you set it on the attendee info/payment options step. |
|
Tony – The code that you referred me to did the trick. Thanks for your help!!! |
|
You’re most welcome, I’m glad it works for you. |
|
The support post ‘EE4: Problem accessing EE objects from within a WP filter function’ 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.