Skip to content

Instantly share code, notes, and snippets.

@moxet
Created December 17, 2024 08:37
Show Gist options
  • Select an option

  • Save moxet/83bdabca265aad94fec4d45933ecd53a to your computer and use it in GitHub Desktop.

Select an option

Save moxet/83bdabca265aad94fec4d45933ecd53a to your computer and use it in GitHub Desktop.

Revisions

  1. moxet created this gist Dec 17, 2024.
    38 changes: 38 additions & 0 deletions gistfile1.txt
    Original 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 );