Reply through REST API do not send notification
-
Hy,
During Implementation I recognize, that a Ticket Reply, created over REST API, do not send a email notification to client or agent.
I use Version 5.8.0 and latest WordPress 4.9.8.
Reason for this issue is, the way you check if a notification is necessary.
Function wpas_notify_reply checks is ID of $data is set, which means it is an update.
In case of REST API you set the complete Post Data into the second parameter, so isset($data[“ID”]) will always be true.I repair this in an unconventionally way in API/TicketReplies.php function update_additional_fields_for_object, so check if it is Update or Create. When Create I remove the ID value. I’m sure you found a better bugfix.
protected function update_additional_fields_for_object( $object, $request ) { $data = get_post( $object->ID, 'ARRAY_A' ); /** * Delete the activity transient. */ delete_transient( "wpas_activity_meta_post_" . $object->ID ); /** * Fire wpas_add_reply_after after the reply was successfully added. */ do_action( 'wpas_add_reply_after', $object->ID, $data ); /** This fix the problem **/ if($request->get_param('id') === null) { unset($data['ID']); } /** * Fire wpas_add_reply_complete after the reply and attachments was successfully added. */ do_action( 'wpas_add_reply_complete', $object->ID, $data ); return parent::update_additional_fields_for_object( $object, $request ); }
- The topic ‘Reply through REST API do not send notification’ is closed to new replies.