Support

Home Forums Event Espresso Premium before_save hook and ee-notices?

before_save hook and ee-notices?

Posted: August 7, 2023 at 6:45 pm

Viewing 3 reply threads


Digital Services Lab

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.


Tony

  • Support Staff

August 8, 2023 at 7:23 am

Hi there,

I am having ongoing issues with some clients not changing the Author field which means I (the admin) end up getting the registration notifications.

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?

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)

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?


Digital Services Lab

August 9, 2023 at 6:40 pm

Do they always use the same admin other than your account?

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.
Generally the issue comes about because they usually duplicate an existing event as a starting point for creating a new event, then update most of the details but tend to always forget the Author.

I’ve managed to work something out using save_post_{$post->post_type} hook

I’ve also got the error message working using EE_Error::add_error()
Cheers.


Tony

  • Support Staff

August 10, 2023 at 5:04 am

Apologies, I forgot to add details on EE_Error::add_error()

Glad you found it.

Viewing 3 reply threads

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.

Event Espresso