Support

Account

Home Forums Front-end Issues acf_form() – action when repeater row added or updated Reply To: acf_form() – action when repeater row added or updated

  • @hube2 Hey, I think I’m missing something, because this isn’t sending the email:

    
    function delegate_form_update($value, $post_id, $field) {
    
    	$order = new WC_Order($post_id);
    
    	// global email settings
    	$to = get_option('admin_email');
    	$headers = array('Content-Type: text/html; charset=UTF-8');
    
    	// this will hold the number of rows - old value
    	$old_rows = intval(get_post_meta($order, 'ticket_alloc', true));
    
    	// count the rows submitted
    	$new_rows = count($_POST['acf']['field_63ca95e88557a']); // field key of repeater
    
    	if($old_rows != $new_rows) {
    		// number of rows has changed		
    		$subject = 'Number of rows has changed';
    		$body = 'This is the mail body';
    		wp_mail($to, $subject, $body, $headers);
    	}
    
    	return $value;
    
    }
    add_filter('acf/update_field/key=field_63ca95e88557a', 'delegate_form_update', 10, 1);