Я использую формы Gravity, и у меня есть автоматическое уведомление. Это уведомление появляется после того, как мое приложение для Android подключается к нему и добавляет запись. Моя проблема в том, что он не выполняет замену переменных.
Так, например, Тема в редакторе форм определяется как Отправка новых приложений для переезда от {Full Name:2}
Но письмо заканчивается как Новое приложение Moving House от.
Все переменные формы заменяются ничем в электронном письме. но если я проверю запись на сайте, она там.
Я добавил свой код в функцию post_entries в Gravity Forms WebApi следующим образом:
public function post_entries($data, $form_id = null) {
$this->authorize('gravityforms_edit_entries');
$result = GFAPI::add_entries($data, $form_id);
if (is_wp_error($result)) {
$response = $this->get_error_response($result);
$status = $this->get_error_status($result);
} else {
$status = 201;
$response = $result;
// This is the form object from Gravity Forms.
$form = \GFAPI::get_form($form_id);
$event = 'form_submission';
$notifications = GFCommon::get_notifications_to_send($event, $form, $lead[0]);
$notifications_to_send = array();
//running through filters that disable form submission notifications
foreach ($notifications as $notification) {
if (apply_filters("gform_disable_notification_{$form['id']}", apply_filters('gform_disable_notification', false, $notification, $form, $lead), $notification, $form, $lead)) {
//skip notifications if it has been disabled by a hook
continue;
}
$notifications_to_send[] = $notification['id'];
}
GFCommon::send_notifications($notifications_to_send, $form, $lead, true, $event);
}
$this->end($status, $response);
}
РЕДАКТИРОВАТЬ: вот рабочий код с помощью Наоми
public function post_entries( $data, $form_id = null ) {
$this->authorize( 'gravityforms_edit_entries' );
$result = GFAPI::add_entries( $data, $form_id );
if ( is_wp_error( $result ) ) {
$response = $this->get_error_response( $result );
$status = $this->get_error_status( $result );
} else {
$status = 201;
$response = $result;
$lead = \GFAPI::get_entry($result);
// This is the form object from Gravity Forms.
$form = \GFAPI::get_form($form_id);
$event ='form_submission';
$notifications = GFCommon::get_notifications_to_send( $event, $form, $lead );
$notifications_to_send = array();
//running through filters that disable form submission notifications
foreach ( $notifications as $notification ) {
if ( apply_filters( "gform_disable_notification_{$form['id']}", apply_filters( 'gform_disable_notification', false, $notification, $form, $lead ), $notification, $form, $lead ) ) {
//skip notifications if it has been disabled by a hook
continue;
}
$notifications_to_send[] = $notification['id'];
}
GFCommon::send_notifications( $notifications_to_send, $form, $lead, true, $event );
}
$this->end( $status, $response );
}