Posted: August 7, 2023 at 6:45 pm
Hello, just want to know if there is an EE4 hook that fires before saving an event that I can use to check/validate the Author field and conditionally prevent save and show a message/error. I am having ongoing issues with some clients not changing the Author field which means I (the admin) end up getting the registration notifications. What I want to do is add some php that fires before save, and check the user in the Author field, and conditionally prevent save (without losing current data) This brings me to the second part, which is, is there a public function for outputting native ee-notices so that I can make the alert/error appear native? I cannot find anything related to either of these things in the docs, but maybe I’m looking in the wrong place. |
|
Hi there,
Do they always use the same admin other than your account? The reason I ask is you could change the message templates to send the emails directly to say the Primary Contact Email rather than the Event Author. Would that help?
We don’t have a hook that fires before save, but EE events are a custom post type, so the fire the save_post hook (after save): https://developer.wordpress.org/reference/hooks/save_post/ You could use that to check the event author and either display a message afterwards or set the author yourself through it. Would that work? |
|
Not necessarily, also depends on the client. Most have numerous people running different types of events and different people should be getting the registration notifications however they often don’t set the author field. I’ve managed to work something out using I’ve also got the error message working using EE_Error::add_error() |
|
Apologies, I forgot to add details on Glad you found it. |
|
The support post ‘before_save hook and ee-notices?’ 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.