• Resolved Jason

    (@zushiba)


    I have created a custom post type that has several fields, dropdowns in this case. And an email address in another field.

    Is there a way to trigger a function when a post is either added or modified?

    What I’m attempting to do is set up a series of entries, and whenever those entries are edited or modified in any way, there is an email fired off to the address in the email field.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yes you can do this via using the add_action( ‘save_post’, ‘save_custom_post_entry’, 10, 3); and check that the post type is what you’re looking for or not using this code

    function save_custom_post_entry( $post_id, $post, $update ){
     $slug = 'your-custom-post-type';
    
        // If this isn't a 'book' post, don't update it.
        if ( $slug != $post->post_type ) {
            return;
        }else{
    // do your job here.
    }
    }

    Hope this will help you.

    Thanks.

    Thread Starter Jason

    (@zushiba)

    Excellent cedcommerce that is what I’m looking for. Thank you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can you trigger a custom function when custom post type entry is updated?’ is closed to new replies.