Support

Home Forums Event Espresso Premium Add action hook for save espresso event

Add action hook for save espresso event

Posted: January 19, 2018 at 1:33 pm

Viewing 3 reply threads


txhomedecor

January 19, 2018 at 1:33 pm

I’ve created a plugin that utilizes the following hook:


add_action( 'save_post', 'xxxxxxxxx' );

However, as you know this save_post occurs on much more than espresso events. I’m trying to get this to only function during creation/edit of espresso events. There was something similar for publishing events here, but that doesn’t seem to be working. I’ve also tried searching through the core code for all AHEE__EE items as well. Any help appreciated.

btw, the save_post hook above does work, but works for much more than it needs to 🙂


Josh

  • Support Staff

January 19, 2018 at 3:16 pm

Hi txhomedecor,

You can actually use save_post, but you’ll need to add a conditional where you check the post type and if the post type isn’t espresso_events, then return.

There’s some example code you can follow in the WordPress codex:

https://codex.wordpress.org/Plugin_API/Action_Reference/save_post#Custom_Post_Type:_.27book.27


txhomedecor

January 19, 2018 at 7:58 pm

yes, i’ve seen that codex as well, but didn’t know if “espresso_events” was the actual type to check for. i’ll give it a shot. thanks.


txhomedecor

January 19, 2018 at 8:28 pm

Thanks Josh, this code did the trick:


//check to see if this event is espresso_events. if so, then create, otherwise return
$post_type = get_post_type($post_id);
if ( "espresso_events" != $post_type ) return;

Viewing 3 reply threads

The support post ‘Add action hook for save espresso event’ 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