最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - Send a conditional email notification when a custom field value changes in Post Type

programmeradmin0浏览0评论

I have added a custom field "Registered"(field type = checkbox) through ACF on Post Type.

When I change the value of the custom post field "Registered" with a check, I want to send email notification to the User Email. Can this be done in any way. I am not too familiar with coding.

I have added a custom field "Registered"(field type = checkbox) through ACF on Post Type.

When I change the value of the custom post field "Registered" with a check, I want to send email notification to the User Email. Can this be done in any way. I am not too familiar with coding.

Share Improve this question edited Aug 10, 2020 at 18:14 Nate Allen 2,1062 gold badges16 silver badges23 bronze badges asked Aug 7, 2020 at 12:58 Muhammad Aurangzeb KhanMuhammad Aurangzeb Khan 11 bronze badge 2
  • do_action('on_acf_post_save'); function on_acf_post_save() { $pid = get_the_ID(); $post_type = get_post_type($pid); $value = get_field('email_sent_indicator', $pid); $value = 'test'; if ($post_type == 'listing-item') { update_field('email_sent_indicator', $value); } } --------------------- I have added this function now, thanks to "mozboz". But heres the thing I cannot update the field of acf. I have tried with "acf/save_post" and also this do_action but both are not updating the value of the field "email_sent_indicator". Btw its a text field in acf – Muhammad Aurangzeb Khan Commented Aug 8, 2020 at 21:45
  • It's not readable to add so much code to a comment like this - it's best to make a new question with your code and a new specific question in it. – mozboz Commented Aug 9, 2020 at 10:46
Add a comment  | 

1 Answer 1

Reset to default 2

There's no way to do this without a bit of programming. You need to look at these pieces:

  • A Wordpress hook like save_post lets you do something when a post is saved or updated
  • wp_mail is how you send an email
  • get_field is how you look at the value of an ACF field.

You'd need to write some code to put them together how you want to, but the details of doing that are beyond the scope of this stack and you'd need to learn some coding, how to run code in Wordpress through a plugin or functions.php

发布评论

评论列表(0)

  1. 暂无评论