cedcommerce on "Can you trigger a custom function when custom post type entry is updated?"

ساخت وبلاگ

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.

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 ) { retu; }else{
// do your job here.
}
}

Hope this will help you.

Thanks.

- - , .
.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 273 تاريخ : پنجشنبه 24 تير 1395 ساعت: 18:34