Created
December 17, 2024 08:37
-
-
Save moxet/83bdabca265aad94fec4d45933ecd53a to your computer and use it in GitHub Desktop.
Revisions
-
moxet created this gist
Dec 17, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ //Use below code in your function.php or code snippet, Open your Jet Form Builder form and insert a hook in action, name your hook as monday. make sure the name of the field map in the requested variable below. add_action('jet-form-builder/custom-action/monday', function( $request, $action_handler ) { $name = $_REQUEST["full_name"]; $email = $_REQUEST["email"]; $contact_number = $_REQUEST["contact_number"]; $message = $_REQUEST["message"]; $token = 'API_KEY_GOES_HERE'; $apiUrl = 'https://api.monday.com/v2'; $headers = ['Content-Type: application/json', 'Authorization: ' . $token]; $query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:1734976586, item_name:$myItemName, column_values:$columnVals) { id } }'; $date = date("Y-m-d"); $vars = [ 'myItemName' => $name, 'columnVals' => json_encode([ 'long_text4' => $message, 'contact_email' => ['email'=> $email, 'text'=> $email], 'date_mkka9zch' => ['date' => $date], 'contact_phone' => ['phone' => $contact_number], 'status' => ['label' => 'Created'] ]) ]; $data = @file_get_contents($apiUrl, false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => $headers, 'content' => json_encode(['query' => $query, 'variables' => $vars]), ] ])); $responseContent = json_decode($data, true); echo json_encode($responseContent); }, 10, 2 );