I want to call some php function to get return calculated value.

Home Forums Quform WordPress I want to call some php function to get return calculated value.

This topic is: resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30745
    choboIsBeginner
    Participant

    Hello! I have some question. I’m not native English speaker, so please understand me and my strange sentences.

    Since before 2 weeks, I tried to call some php function in functions.php in Avada child theme. But I can’t get return value. Only I got is headache… 🙁

    I want to call this function and get return value in 9th page of my Quform form (form consists of 10 pages). This function works with hundreds of [$form->getValue(‘quform_1_761’)] and it return some text(consist of hundreds of (south)Korean characters) which contains some diagnosis of certain legal issue.

    Fortunally, it works very well with [add_filter(‘quform_confirmation_message_1_1’, ‘confMessage’, 10, 3);] yeah it is pleasure for me. I almost made it with Quform. Quform and developers are great.

    But of course, [quform_confirmation_message_1_1] only works with clicking submit button which is in 10th page. end of end of form… I want to call this function and get return value in end of 9th page, and display returned value in some element of 10th page, like HTML element. I have to display returned result to end user and, take a name and phone numbers of that user with some text field elements, and send email automatically to my collague, which contains input of end users, returned result, and name and phone numbers of user. With several ways I tried to do that, and email is OK with PHPMailer, but I can’t get result in the end of 9page… 🙁

    Anyone, especially demi-god Quform developers, please tell me the way of do that. No matter use any technology(DB, Ajax, php, js, …), no matter how difficult it is. I’m a beginner of web programming anyway. I will learn and use it. Ah of course easy is good… 😉

    Yeah my mental is broken so question was self-pity, too long and messy. Sorry. I want to write some more, so I write that in appendix which is placed in below.

    Appendix 1 : During write this question, suddenly I came up with some way. Like 2 of appendix 2, but use MySQL DB instead of global variable. but I don’t know way to use MySQL. I just know MSSQL/SQLite little bit… Until answer is arrived, I do learn the way use MySQL in Quform… Of course there is the better or/and easy way, please tell me 🙂

    Appendix 2 : 2 ways to get return value I did.

    1. I did use [quform_pre_validate_1] and [if ($_POST[‘quform_submit’] != ‘back’ && $form->getNextPageId() == 772)], do [$form->setValue(‘quform_1_750’);] in backand, and do [jQuery(‘.quform-field-1_750’).val()] in the frontend. Fail.

    2. I type some code like below. Epic fail. Global variable is not worked. What the…


    $resultCalculator = ResultClass::getInstance(); // singleton
    $GLOBALS[‘result’] = ‘resultInitVal’; // Ajax passed this… What the…

    // for calculate result value when 9th page is finished
    add_filter(‘quform_pre_validate_1’,
    function (array $result, Quform_Form $form)
    {
    // blabla…
    else if ($_POST[‘quform_submit’] != ‘back’ && $form->getNextPageId() == 772) // 772 = 10th page id
    {
    global $GLOBALS, $resultCalculator;
    $GLOBALS[‘result’] = $resultCalculator->calcAndDisplay($form);

    $path = ‘blabla…\\debug.log’;
    file_put_contents($path, $GLOBALS[‘result’], FILE_APPEND);

    return array(‘type’ => ‘page’, ‘page’ => 772);
    }
    // blabla…
    }
    , 10, 2);

    // for Ajax php side 1
    function enqueue_ajax_script() {
    $path = ‘/wp-content/plugins/quform/cache/custom.js’;

    wp_enqueue_script(‘jquery’);
    wp_enqueue_script(‘ajax’, $path );

    wp_localize_script(‘ajax’, ‘ajax_object’,
    array(‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), ‘we_value’ => 1234 ) );
    }
    add_action (‘wp_enqueue_scripts’, ‘enqueue_ajax_script’);

    // for Ajax php side 2
    function callme_func() {
    global $GLOBALS;

    $buf = $GLOBALS[‘result’];
    echo $buf;

    wp_die();
    }
    add_action(‘wp_ajax_callme’, ‘callme_func’);
    add_action(‘wp_ajax_nopriv_callme’, ‘callme_func’);

    // javascript side
    jQuery(document).ready(function ($)
    {
    jQuery(‘.quform-next-1_750’).bind(‘click’, // Next button to go to 10th page
    function()
    {
    var result = ”;

    jQuery.get(ajax_object.ajax_url, {‘action’:’callme’}, function(response) {
    result = response;
    });
    jQuery(‘.quform-element-1_779>.quform-spacer’).html(result);
    }
    );
    // blabla…
    }

    #30754
    choboIsBeginner
    Participant

    Sorry. I can’t apply style to my source code like below… 🙁 All contents of editbox is code! -> I do eject all code from editbox. It was so messy 🙁

    #30764
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #30774
    choboIsBeginner
    Participant

    Thank you for your help. South korea is now night. I will apply your solution tomorrow and tell you again.

    #30778
    choboIsBeginner
    Participant

    Yeah your solution works very well. You are angel, demi-god, superman. Just 50 days ago, I knew nothing about the web and WordPress. I finally did it with Quform and your help. I was worried about what to use between Quform and ninja form. But now I don’t know what a ninja form is. Is it food? Delicious? I only know Quform is only one WordPress form solution. Nothing else can exist.

    I want to show you what I made with Quform. It is all in Korean language, but I want to show it to you anyway. I did it because Quform and you are great.

    Korean URL : delete 🙂
    English URL : delete 😉

    Thank you again 😉

    Appendix : The program contains code for making legal judgments. I didn’t want to expose it to our competitor lawfirms, so I had to use php instead of JS.

    #30785
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2019 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy