I apologize for the confusion. Here are fully functional code examples for each case mentioned earlier:
Add Help Scout note for a specific entry
This example adds a Help Scout note when the ‘gform_entry_list_action_helpscout’ action is triggered for a specific entry.
add_action('gform_entry_list_action_helpscout', 'add_helpscout_note', 10, 2); function add_helpscout_note($entry_id, $form) { // Replace with your Help Scout API key $api_key = 'your_helpscout_api_key'; // Replace with the appropriate Help Scout conversation ID $conversation_id = 'your_conversation_id'; $note_text = "A note added from Gravity Forms entry ID: {$entry_id}"; $url = "https://api.helpscout.net/v2/conversations/{$conversation_id}/notes"; $args = array( 'headers' => array( 'Authorization' => 'Basic ' . base64_encode($api_key . ':X'), 'Content-Type' => 'application/json' ), 'body' => json_encode(array( 'text' => $note_text )), 'method' => 'POST', 'sslverify' => false, ); $response = wp_remote_request($url, $args); if (is_wp_error($response)) { error_log("Error adding Help Scout note: " . $response->get_error_message()); } }
Send an email to support when Help Scout action is triggered
This example sends an email to support whenever the ‘gform_entry_list_action_helpscout’ action is triggered.
add_action('gform_entry_list_action_helpscout', 'email_support', 10, 2); function email_support($entry_id, $form) { $to = '[email protected]'; $subject = 'Help Scout action triggered'; $message = "A Help Scout action was triggered for Gravity Forms entry ID: {$entry_id}"; $headers = 'From: Gravity Forms <[email protected]>'; wp_mail($to, $subject, $message, $headers); }
Log Help Scout action to a custom log file
This example logs the ‘gform_entry_list_action_helpscout’ action to a custom log file.
add_action('gform_entry_list_action_helpscout', 'log_helpscout_action', 10, 2); function log_helpscout_action($entry_id, $form) { $log_file = 'helpscout_action.log'; $current_time = date('Y-m-d H:i:s'); $log_message = "[{$current_time}] Help Scout action triggered for Gravity Forms entry ID: {$entry_id}" . PHP_EOL; file_put_contents($log_file, $log_message, FILE_APPEND); }
Update the entry status when Help Scout action is triggered
This example updates the entry status when the ‘gform_entry_list_action_helpscout’ action is triggered.
add_action('gform_entry_list_action_helpscout', 'update_entry_status', 10, 2); function update_entry_status($entry_id, $form) { $entry = GFAPI::get_entry($entry_id); $entry['status'] = 'trash'; GFAPI::update_entry($entry); }