publish_post hook trigger twice when I publish post
-
I am trying to send email post content on post publish and written small function in functions.php but it fires twice I am getting same mail 2 times. I am using wordpress version 5.2.2. Please find code below:
function send_members($ID, $post) { global $wpdb; if( ! ( wp_is_post_revision($post->ID) || wp_is_post_autosave($post->ID) ) ) { $cat = get_the_category($post->ID); if($cat[0]->cat_ID = 40){ $tableusers = $wpdb->prefix.DB_TABLE_BTC_MLM_USERS; $users = 'abc@gmail.com'; $subject = $post->post_title; $body = $post->post_content; wp_mail($users, $subject, strip_tags($body)); return; } } } add_action('publish_post', 'send_members',10,2);
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘publish_post hook trigger twice when I publish post’ is closed to new replies.