WordPress PHP

[SOLVED] Notifications dont't work when submitting a form on GravityForm API

by Daniel Loureiro on 1 min read

By default, notifications only work when submitting through the web interface. If you are submitting forms using the REST API, notifications will be ignored.

Solution: Add this code to your functions.php (Appearance > Theme Editor > functions.php):

/**
 * Force notifications when submiting a GravityForm via REST API.
 */
add_action( 'gform_post_add_entry', 'add_entry_callback', 10, 2 );
function add_entry_callback( $entry, $form ) {
  if ( 1 === $form['id'] ) {
    GFAPI::send_notifications( $form, $entry );
  }
}

WARNING

NOTICE: Replace 1 with your form ID.


Comments

Copyright 2022 - Daniel Loureiro