• Resolved StarryMom

    (@starrymom)


    We have the pro version of the plugin but support has yet to respond to the issues we are having.

    First, the error I originally reached out with:

    PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function BitApps\BTCBI_PRO\Triggers\Kadence\KadenceController::handle_kadence_form_submit(), 3 passed in /public/wp-includes/class-wp-hook.php on line 324 and exactly 4 expected in /public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php:162
    Stack trace:
    #0 /public/wp-includes/class-wp-hook.php(324): BitApps\BTCBI_PRO\Triggers\Kadence\KadenceController::handle_kadence_form_submit()
    #1 /public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #2 /public/wp-includes/plugin.php(517): WP_Hook->do_action()
    #3 /public/wp-content/plugins/kadence-blocks/includes/advanced-form/advanced-form-ajax.php(106): do_action()
    #4 /public/wp-includes/class-wp-hook.php(324): KB_Ajax_Advanced_Form->process_ajax()
    #5 /public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #6 /public/wp-includes/plugin.php(517): WP_Hook->do_action()
    #7 /public/wp-admin/admin-ajax.php(207): do_action()
    #8 {main}
    thrown in /public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php on line 162

    In your documentation it says it should work with Kadence ADVANCED form block. Yet in the code it’s set to work with the basic Kadence form block.

    Ok, easy enough for me to fix. You can run this through a diffchecker to see my changes in the file at: /bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php


    <?php

    namespace BitApps\BTCBI_PRO\Triggers\Kadence;

    use BitCode\FI\Flow\Flow;

    final class KadenceController
    {
    public static function info()
    {
    $plugin_path = self::pluginActive('get_name');

    return [
    'name' => 'Kadence Blocks Form',
    'title' => 'Kadence Blocks Form - Flexible and Design-Friendly Contact Form builder plugin for WordPress',
    'slug' => $plugin_path,
    'pro' => 'kadence-blocks-pro/kadence-blocks-pro.php',
    'type' => 'form',
    'is_active' => self::pluginActive(),
    'activation_url' => wp_nonce_url(self_admin_url('plugins.php?action=activate&amp;plugin=' . $plugin_path . '&amp;plugin_status=all&amp;paged=1&amp;s'), 'activate-plugin_' . $plugin_path),
    'install_url' => wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_path), 'install-plugin_' . $plugin_path),
    'list' => [
    'action' => 'kadence/get',
    'method' => 'get',
    ],
    'fields' => [
    'action' => 'kadence/get/form',
    'method' => 'post',
    'data' => ['id']
    ],
    'isPro' => true
    ];
    }

    public static function pluginActive($option = null)
    {
    if (is_plugin_active('kadence-blocks-pro/kadence-blocks-pro.php')) {
    return $option === 'get_name' ? 'kadence-blocks-pro/kadence-blocks-pro.php' : true;
    }

    return false;
    }

    public static function get_all_forms()
    {
    global $wpdb;
    $forms = $wpdb->get_results("select id,post_title,post_content from {$wpdb->posts} where post_content like '%<!-- wp:kadence/advanced-form%' and post_status = 'publish'");

    return $forms;
    }

    public function getAll()
    {
    if (!self::pluginActive()) {
    wp_send_json_error(__('Kadence Blocks is not installed or activated', 'bit-integrations'));
    }

    $forms = self::get_all_forms();
    $all_forms = [];
    foreach ($forms as $key => $val) {
    $form_id = $val->id;
    $form_title = $val->post_title;
    $form_content = $val->post_content;

    $contentArray = explode('<!--', $form_content);
    $content = [];
    foreach ($contentArray as $key => $value) {
    if (str_contains($value, ' wp:kadence/advanced-form')) {
    $temp = str_replace(' wp:kadence/advanced-form', '', $value);
    $temp1 = explode('-->', $temp, 2);
    $content[] = json_decode($temp1[0]);
    }
    }

    if (\is_array($content)) {
    foreach ($content as $form) {
    $parent_id = $form->postID;
    $unique_id = $form->uniqueID;
    $all_forms[] = (object) [
    'id' => $form_id . '_' . $unique_id,
    'title' => $form_title . '_' . $unique_id,
    'parent_id' => $parent_id,
    ];
    }
    }
    }
    wp_send_json_success($all_forms);
    }

    public function get_a_form($data)
    {
    if (!self::pluginActive()) {
    wp_send_json_error(__('Kadence Blocks is not installed or activated', 'bit-integrations'));
    }
    if (empty($data->id)) {
    wp_send_json_error(__('Form doesn\'t exists', 'bit-integrations'));
    }

    $fields = self::fields($data->id);

    if (empty($fields)) {
    wp_send_json_error(__('Form doesn\'t exists any field', 'bit-integrations'));
    }

    $responseData['fields'] = $fields;
    wp_send_json_success($responseData);
    }

    public static function parseData($form_id)
    {
    $posDelimeter = strpos($form_id, '_');
    $post_id = substr($form_id, 0, $posDelimeter);
    $unique_id = substr($form_id, $posDelimeter + 1);
    $condition = '%wp:kadence/advanced-form {"uniqueID":"' . $unique_id . '"%';
    global $wpdb;
    $formInfo = $wpdb->get_results("select post_content from {$wpdb->posts} where post_content like '{$condition}' and post_status = 'publish'");

    $form_content = $formInfo[0]->post_content;
    $contentArray = explode('<!--', $form_content);
    $formFields = [];
    foreach ($contentArray as $key => $value) {
    $tmpStr = ' wp:kadence/advanced-form {"uniqueID":"' . $unique_id . '","postID":"' . $post_id . '"';
    if (str_contains($value, $tmpStr)) {
    $temp = str_replace(' wp:kadence/advanced-form', '', $value);

    $temp1 = explode('><', $temp);

    $cnt = 0;
    foreach ($temp1 as $key1 => $value1) {
    if (str_contains($value1, 'data-type')) {
    $regularExpressionName = '/name\s*=\s*"([^"]+)"/';
    preg_match($regularExpressionName, $value1, $fieldName);
    $regularExpressionId = '/id\s*=\s*"([^"]+)"/';
    preg_match($regularExpressionId, $value1, $fieldId);
    $regularExpressionDataLabel = '/data-label\s*=\s*"([^"]+)"/';
    preg_match($regularExpressionDataLabel, $value1, $fieldDataLabel);
    $regularExpressionDataType = '/data-type\s*=\s*"([^"]+)"/';
    preg_match($regularExpressionDataType, $value1, $fieldDataType);

    $formFields[] = (object) [
    'name' => $fieldName[1],
    'type' => strtolower(isset($fieldDataType[1]) ? $fieldDataType[1] : 'text'),
    'label' => isset($fieldDataLabel[1]) ? $fieldDataLabel[1] : $fieldId[1],
    ];
    }
    }
    }
    }

    return $formFields;
    }

    public static function fields($form_id)
    {
    $fields = [];

    return self::parseData($form_id);
    }

    public static function handle_kadence_form_submit($form_args, $fields, $form_id, $post_id)
    {
    if (!$form_id) {
    return;
    }
    $flows = Flow::exists('Kadence', $post_id . '_' . $form_id);
    if (!$flows) {
    return;
    }
    $data = [];
    foreach ($fields as $key => $field) {
    $data['kb_field_' . $key] = $field['value'];
    }
    Flow::execute('Kadence', $form_id, $data, $flows);
    }
    }

    However, I now get the following error when pulling in the form fields:

    “Events fetching failed. please try again”

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support wayes001

    (@wayes001)

    We have thoroughly investigated the issue on our site and did not notice the error you mentioned. For now, you can use the “Action Hook” trigger to connect Kadence with Google Sheets.

    Please check the details here:

    You can achieve this using the “Action Hook” trigger in Bit Integrations.

    Here are the steps to achieve this:

    1. Select “Action Hook” as the trigger.
    2. Choose “Kadence Blocks Form” option from the “Hook” dropdown.
    3. Click on the fetch button.
    4. Now open your Kadence Form and submit the form.
    5. The fetched data will include details like: 0 (Object), 1 (Array), 2 (5_5b93a9-f4), 3 (5).
    6. Add a unique key, which typically corresponds to the form’s unique ID (e.g., 5_5b93a9-f4).
    7. Select the form field under 1 (Array) and then select the form value (Value) for each field under Object.
    8. Proceed to the next step on the Action page and set up the action according to your requirements.

    For a more detailed explanation, please refer to this video tutorial.

    If you have any further questions or need assistance, feel free to ask!

    If you need any more help or revisions, please let me know!

    Thread Starter StarryMom

    (@starrymom)

    I’ve tried that, and nothing happens, it shows a red stop button and that’s it, just “runs” and I waited 5 minutes.

    Remember, per your documentation, I am using the Kadence ADVANCED Form Block. I have many forms set up using that specific block.

    Thread Starter StarryMom

    (@starrymom)

    Here’s some of the errors (with a fresh copy of the Bit Integrations Pro plugin):

    [13-Jun-2024 20:17:14 UTC] PHP Warning:  Undefined array key 0 in /public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php on line 120


    [13-Jun-2024 20:17:14 UTC] PHP Warning: Attempt to read property "post_content" on null in /public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php on line 120


    [13-Jun-2024 20:17:14 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php on line 121

    Also, remember, in the code and database, with the ADVANCED form block, it needs to be

    wp:kadence/advanced-form

    But you ONLY have support for the BASIC form block with wp:kadence/form, which is what your code uses.

    I would love if you could prove to me with a screen recording that your plugin works with the Kadence ADVANCED Form Block as you claim it does because I don’t see how it can with this code.

    Plugin Support wayes001

    (@wayes001)

    Hello Sara, 

    Yes, Bit Integrations doesn’t have any integration with Kadence Advanced Form. It has integration with Kadence Basic Form. However, you can integrate the Kadence Advanced Form via “Action Hook Trigger.”

    Please check the details here:

    You can achieve this using the “Action Hook” trigger in Bit Integrations.

    Here are the steps to achieve this:

    1. Select “Action Hook” as the trigger.
    2. Choose “Custom” option from the “Hook” dropdown.
    3. Add the hook for Kadence Advanced form which is “kadence_blocks_advanced_form_submission”
    4. Click on the fetch button.
    5. Now open your Kadence Advanced Form and submit the form.
    6. The fetched data will include details like: 0 (Object), 1 (Array), 2 (11), Here 11 is form Id
    7. Add a unique key, which typically corresponds to the form’s unique ID 2 (11), Here 11 is form Id.
    8. Select the form field under 1 (Array) and then select the form value (field_value) for each field under Object.
    9. Proceed to the next step on the Action page and set up the action according to your requirements.

    For a more detailed explanation, please refer to this: https://www.loom.com/share/07c56af659f6427d8cee636b5b0abaa8

    If you have any further questions or need assistance, feel free to ask!

    If you need any more help or revisions, please let me know!

    • This reply was modified 5 months, 2 weeks ago by wayes001.
    Thread Starter StarryMom

    (@starrymom)

    I guess we are posting here and emailing the same thing? It’s Sarah, fyi.

    Your documentation clearly stated ADVANCED form.

    I do see that you changed the documentation to remove the word advanced. Google still shows it though.

    As I’ve said, the fetch button does nothing. I see in my access logs the following: “POST /wp-admin/admin-ajax.php?action=btcbi_action_hook%2Ftest&_ajax_nonce=de9b6e96ed HTTP/2.0” and that just repeats over and over and over until I click the stop button. Nothing in PHP error or error logs.

    Thread Starter StarryMom

    (@starrymom)

    When I caved and switched to using the Kadence Form Block for this one and only form that needs this plugin, if I enable the integration it causes all of my other Kadence forms which use the advanced form block to give a 500 error.

    PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function BitApps\BTCBI_PRO\Triggers\Kadence\KadenceController::handle_kadence_form_submit(), 3 passed in /home/nginx/domains/public/wp-includes/class-wp-hook.php on line 324 and exactly 4 expected in /home/nginx/domains/public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php:162
    Stack trace:
    #0 /home/nginx/domains/public/wp-includes/class-wp-hook.php(324): BitApps\BTCBI_PRO\Triggers\Kadence\KadenceController::handle_kadence_form_submit()
    #1 /home/nginx/domains/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #2 /home/nginx/domains/public/wp-includes/plugin.php(517): WP_Hook->do_action()
    #3 /home/nginx/domains/public/wp-content/plugins/kadence-blocks/includes/advanced-form/advanced-form-ajax.php(106): do_action()
    #4 /home/nginx/domains/public/wp-includes/class-wp-hook.php(324): KB_Ajax_Advanced_Form->process_ajax()
    #5 /home/nginx/domains/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #6 /home/nginx/domains/public/wp-includes/plugin.php(517): WP_Hook->do_action()
    #7 /home/nginx/domains/public/wp-admin/admin-ajax.php(207): do_action()
    #8 {main}
    thrown in /home/nginx/domains/public/wp-content/plugins/bit-integrations-pro/includes/Triggers/Kadence/KadenceController.php on line 162
    Plugin Support wayes001

    (@wayes001)

    We want to inform you that we have already fixed the issue. The resolution will be included in the next update of Bit Integrations. Therefore, please wait for the next update.

    Thread Starter StarryMom

    (@starrymom)

    When will the update be released? We purchased the plugin almost a month ago and have yet been able to use it without numerous issues.

    Thread Starter StarryMom

    (@starrymom)

    I emailed asking for a refund.

    How an update makes things worse, I’ll never understand. It completely breaks the Kadence Advanced Form Block now, it won’t even load on the backend.

    This is unacceptable for a paid service. We purchased it weeks ago and all it’s done is not work and break the site.

    Plugin Support wayes001

    (@wayes001)

    We would like to let you know we have improve the Kadence trigger.
    Please update your plugin to the lates version and try. The latest version of Bit Integrations is free v2.1.0 and free v2.0.9. If you face any further issues please let us know.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.