Customize the new comment notifications sent to the post author after the comment is approved

Initially it seemed like a good idea to add comment_notification_text inside the pre_comment_on_post hook, but it didn’t go well. So I removed the pre_comment_on_post and just added to comment_notification_text a comment type check, which is related to the CPT for which the comments are. Now my code works fine for both comment categories (moderated and … Read more

Only Admin receives email

Mail sent from WP uses wp_mail() function. There is a filter that you can use before the mail is sent to filter the arguments used in the wp_mail() function, including the $to value. See https://developer.wordpress.org/reference/hooks/wp_mail/ Look at the example code on that page to get an idea of how to block (or redirect) all mail … Read more

Admin notice on wp_insert_post

Hooks cannot be added directly inside functions. Using do_action, you can invoke a custom hook. In your case try out the below solution: add_action( ‘wp_insert_post’, ‘automate_intercom’, 10, 3 ); function automate_intercom( $post_id, $post, $update ) { if ( $post->post_status == ‘publish’ && $post->post_type == ‘help-center’ ) { $someCondition = ”; if ( $someCondition !== ” … Read more

Call API on post save/update and show the result in admin area

You can’t do that with PHP. You must use Javascript-React to alter/enhance block editor behaviour. You’ll have to use subscribe function, for subscribing to actions, catch isSavingPost action there (there is also isAutoSavingPost for autosaves) and dispatch a Notice in the editor with appropriate action. Familiarity with React and Redux would be of great help.