• ashraj98

    (@ashraj98)


    I am using Gravity Forms to display the results of an API Call. I had it working correctly until I switched themes and updated GF. Now when I click submit the page loads then just stops.

    Here is my code:

    add_action(“gform_after_submission”, “set_post_content1”, 10, 2);

    function set_post_content1($entry, $form){
    $url=strtok($_SERVER[“REQUEST_URI”],’?’);
    $uid = get_current_user_id();
    if (isset($entry[“1”]) {
    $url = “https://www.—————.com/api/———–?v=2&key=———-&multiplier=———-&images=————&items=” . urlencode($entry[“1”]);
    $response = wp_remote_get($url);
    $json = $response[“body”];

    $post = get_post($entry[“post_id”]);

    if (empty($json)) {
    $post->post_content = “No results received. Sorry! Please refresh the page and search again”;
    return;
    }

    $results = json_decode($json, true);
    $total = 0;
    print_r($results);
    $r = $results[“data”][“0”];

    if (isset($r[“error”]) && $r[“error”] = 2) {
    $post->post_content =
    “<div>
    <p>——————————————————–p>
    </div>”;
    } else {
    $total = $total + $r[‘worth’][$entry[“2”]];
    $append = $uid . $r[‘search_term’] . $total;
    $clean_url = “https://www.——————-.me/—————/————/&#8221; . $append . “.jpg”;
    $post->post_content =
    ‘<div>
    <h1>’ . $r[‘search_term’]; . ‘</h1>
    <p></p>
    <img src=”‘ . ‘https://&#8217; . str_replace(‘ ‘, ”,urldecode($r[‘search_term’])) . ‘.jpg.to’ . ‘”>
    <p></p>
    <p> —————————‘ . $r[‘worth’][$entry[“2”]] . ‘—. </p>
    </div>
    <div>
    <p>——————————-</p>
    <p>——————————-</p>
    <p>——————————-</p>
    <p>——————————-</p>
    <p>——————————-</p>
    <p>——————————–</p>
    <p>——————————–</p>
    <p>——————————–</p>
    <img src=”‘ . $clean_url . ‘”>
    <p>——————————–</p>
    <p>———————————</p>
    <p>———————————</p>
    <p>———————————</p>
    <p>———————————</p>

    • ————-
    • ————-
    • ————-
    • ————-

    <p></p>
    <p>———-</p>
    </div>’;
    <?php
    }
    }
    wp_update_post($post);
    }

    I’m not sure if there is an error here or something wrong with my new theme. Thanks!

  • The topic ‘Gravity Forms gform_after_submission Custom Confirmation’ is closed to new replies.