• Resolved ryandrewniak

    (@ryandrewniak)


    Is there any way to hook into this plugin to record 3rd party form submissions?

    I have a manually built form which I’d like to integrate into the system, if possible, and record the submissions for security purposes. Can this be done? If so, can you point me in the right direction for how to make that happen?

    • This topic was modified 7 years, 8 months ago by ryandrewniak.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author jasongreen

    (@jasongreen)

    Hi

    Yeah you can definitely use my plugin to save a submission. This code isn’t tested but something like this should work:

    $submission = array(
        'form_id'   => 0,
        'body'      => '',
        'sender'    => '',
        'subject'   => '',
        'recipient' => '',
        'additional_headers' => '',
        'attachments' => array('field'=>'file_path',...),
        'fields'    => array('field'=>'value',...)
    );
    global $contact_form_submissions;
    $contact_form_submission_id = $contact_form_submissions->save($submission);
    Thread Starter ryandrewniak

    (@ryandrewniak)

    Sweet! I’ll give it a shot and let you know if I can get it to work.

    Thread Starter ryandrewniak

    (@ryandrewniak)

    I gave it a go, and I can’t seem to get it to work.

    I have the form submission making an AJAX call to a method in my functions.php file (successfully making the call to that function). Everything seems to be functioning, until I make the call to the $contact_form_submissions object. This is what my method in my functions.php file looks like:

    function save_simple_pay_dbsubmission() {
    	global $contact_form_submissions;
    
    	// Get current timestamp for database submission
    	$d = new DateTime('', new DateTimeZone('America/Edmonton'));
    	$timestamp = $d->format('Y-m-d [G:i:s]');
    
    	$submission = array(
    	    'form_id'   => 0,
    	    'body'      => '',
    	    'sender'    => '',
    	    'subject'   => $sess['product-desc'],
    	    'recipient' => '',
    	    'additional_headers' => '',
    	    'attachments' => array(),
    	    'fields'    => array(
    			'bill-first-name' => $sess['bill_first_name'],
    			'bill-last-name' => $sess['bill_last_name'],
    			'email' => $sess['email'],
    			'bill-phone' => $sess['bill_phone'],
    			'bill-address' => $sess['bill_address_one'],
    			'bill-city' => $sess['bill_city'],
    			'bill-province' => $sess['bill_state_or_province'],
    			'bill-country' => $sess['bill_country'],
    			'bill-postal-code' => $sess['bill_postal_code'],
    			'product-description' => $sess['product-desc'],
    			'product-single-price' => $sess["price1"],
    			'product-quantity' => $sess['quantity1'],
    			'subtotal' => $sess['subtotal1'],
    			'charge-total' => $sess['charge_total'],
    			'timestamp' => $timestamp
    	    )
    	);
    
    	$db_submission = $contact_form_submissions->save($submission);
    
    	return 'SUCCESSFUL DATABASE SUBMISSION';
    }

    Like I said, I’m able to make the AJAX call to that function. If I comment out the $db_submission variable, I can get the successful return (I’ve been able to log it to the console).

    Is there something that you can see that is inherently wrong with this plan or my code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hook for 3rd party form submission’ is closed to new replies.