Home › Forums › Quform WordPress › Sending form data to another script
- This topic has 2 replies, 2 voices, and was last updated 7 years, 4 months ago by
Ally.
- AuthorPosts
- May 5, 2018 at 10:26 pm #25507
cmsadmin
ParticipantI’ve followed the documentation as described here: https://support.themecatcher.net/quform-wordpress-v2/guides/integration/sending-form-data-to-another-script
The form values are being send to script.php in my child theme. How can I assign new variables to values from the ‘body’ array that wp_remote_post sends?
And will my script.php run when it receives the data?
// Frank
May 6, 2018 at 9:24 am #25512cmsadmin
ParticipantAfter digging around I noticed that the body is not printed to debug.log. Therefore I think the body is not being send at all. Atleast this explains why I cannot acces the array in my script.php.
add_action('quform_post_process_1', function (array $result, Quform_Form $form){ $data = array( 'forename' => $form->getValue('quform_1_5'), 'surname' => $form->getValue('quform_1_6'), 'email' => $form->getValue('quform_1_4'), 'telephone' => $form->getValue('quform_1_7'), 'street' => $form->getValue('quform_1_10'), 'number' => $form->getValue('quform_1_11'), 'zipcode' => $form->getValue('quform_1_8'), 'city' => $form->getValue('quform_1_9') ); $response = wp_remote_post('http://mywebsite/wp-content/themes/theme-child/script.php', array( 'body' => $data )); if (defined('WP_DEBUG') && WP_DEBUG) { if (is_wp_error($response)) { Quform::log($response->get_error_message()); } else { $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); Quform::log('HTTP status code: ' . $code, $body); } } return $result; }, 10, 2);
Results in this log:
[06-May-2018 08:20:13 UTC] string(21) "HTTP status code: 200" [06-May-2018 08:20:13 UTC] string(0) ""
- This reply was modified 7 years, 4 months ago by
Ally.
May 8, 2018 at 11:04 pm #25585Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 7 years, 4 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.