• Resolved htausch

    (@htausch)


    I have a form that is already storing data in the database. I’d like the results of that database to be pulled into the plugin. I’ve been able to do this by creating a short code in the functions file in the past by using something like:

    $results = $wpdb->get_results (“SELECT * FROM my_form_name”)
    foreach ( $results as $result ) {
    $result->email;
    };

    But I’d like it to interface with your plugin. Do you have a guide on how to do this?

    Also, when adding custom functionality to your plugin. Where do I enter the code? My functions file?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter htausch

    (@htausch)

    I’m sorry, I meant my_database_name not my_form_name

    Thread Starter htausch

    (@htausch)

    Also, I should note that I can’t figure out how to add your [cfdb-save-form-post] to the post url because I am using AJAX to dynamically post (at least I believe, I didn’t write this code and have very little experience with AJAX).

    function Calculate_Ft() {
    	var FormData=jQuery('#frmcalculator').serialize();
    	jQuery('#calresult').hide();
    	jQuery.ajax({
    		type : 'POST',
    		url : myAjax.ajaxurl, 
    		data : FormData+"&action=ft_calculator",
    		dataType : "json",
    		async :false,
    		success :function(data){
    			jQuery('#calresult').show();
    			jQuery('#calresult').html(data.result);			
    		}
    	});
    }

    And then in the template file we have:

    <form name="frmcalculator" id="frmcalculator" role="form">
    <label>Some Inputs Here</label>
    <input type="text" name="email" id="email" />
    <button type="button" onclick="Calculate_Ft();">CALCULATE</button>
    
    <div class="results">
        <div id="calresult">
        </div>
    </div>
    </form>

    The ft_calculator() function is defined in the functions file. That is where it is telling the form what database to store in.

    • This reply was modified 7 years, 8 months ago by htausch.
    • This reply was modified 7 years, 8 months ago by htausch.
    • This reply was modified 7 years, 8 months ago by htausch.
    Plugin Author Michael Simpson

    (@msimpson)

    The plugin doesn’t support pulling in data from other database tables.

    [cfdb-save-form-post] does not work with ajax submissions. But in the code that handles that ajax submitssion, you could add do_shortcode('[cfdb-save-form-post]');

    Thread Starter htausch

    (@htausch)

    Ok, so reading your documentation and comments further I solved it.

    I followed Step One from here.

    And then I added the code mentioned here.

    Meaning I added this to my function in my functions.php file:

    function ft_calculator() {
      		require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBShortCodeSavePostData.php');
      		$handler = new CFDBShortCodeSavePostData;
      		$handler->handleShortcode(null);
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pull in data from custom DB’ is closed to new replies.