Support

Account

Home Forums ACF PRO Check if field has changed when save to change mail Reply To: Check if field has changed when save to change mail

  • Let’s say that your field name is “text_field” and it has a field key of “field_123456”
    Notice I’m only using the field key, since you must use the field key for the new values you might just as well use it for both.

    
    add_filter('acf/save_post', 'my_compare_acf_fields', 1);
    function my_compare_acf_fields($post_id) {
      $old_value = get_field('field_123456', $post_id);
      $new_value = '';
      if (isset($_POST['acf']['field_123456'])) {
        $new_value = $_POST['acf']['field_123456'];
      }
      if ($new_value != $old_value) {
        // value has changed, do something
      }
    }