Forum Replies Created
- AuthorPosts
jwrbloom
ParticipantStill getting…
Fatal error: Uncaught Error: Call to undefined function add_filter() in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php:4 Stack trace: #0 {main} thrown in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php on line 15
/** * Plugin Name: CSI Stats * Plugin URI: https://courtsideindiana.com * Description: Stat Module * Version: 1.0 */ //include("/home2/csi/public_html/resources/con.php"); add_filter('quform_post_process_10', function (array $result, Quform_Form $form) { $session = quform('session'); $session->set('form_10', $form); return $result; }, 10, 2); add_action('wp', function () { if(!isset($_GET['submitted_form_csv']) || !function_exists('quform')) { return; } $session = quform('session'); $form = $session->get('form_10'); if(!$form instanceof Quform_Form) { die('Form not found'); } var_dump($form->getValues()); exit; });
Here is the URL I’m redirecting to:
https://www.courtsideindiana.com/wp-content/plugins/csi_stats/csi_roster_process.php?submitted_form_csvjwrbloom
ParticipantTried both codes blocks separately, and they each produced this error:
Fatal error: Uncaught Error: Call to undefined function add_filter() in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php:3 Stack trace: #0 {main} thrown in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php on line 3
What I want is to submit the form, have it redirect to a .php and dump the data so I can treat it like a CSV.
- This reply was modified 4 years, 7 months ago by
jwrbloom.
jwrbloom
ParticipantJust answering the question you asked, then I’ll try out the code you posted.
I’m sending the form to the PHP via the form’s settings.
Settings > Confirmation > Default Confirmation > Display message then redirect to custom URL
jwrbloom
ParticipantI’ve tried getValues() as well.
Same error.
However, do I need to code in the array too? I’m just looking for a way to have all the data dumped.
jwrbloom
ParticipantThat was the full code.
Then I marked that out and put this:
add_action('quform_get_value_for_storage_10', function ($value, Quform_Element_Field $element, Quform_Form $form) { $value = my_encrypt_element_value($value); return $value; }, 10, 3);
Same error.
jwrbloom
ParticipantJust sending the form to a .php to try this out:
$value = $form->getValue(‘quform_10_60’);I keep getting this error:
Fatal error: Uncaught Error: Call to a member function getValue() on null in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php:4 Stack trace: #0 {main} thrown in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_process.php on line 4Here is my code:
$value = $form->getValue('quform_10_60'); echo $value; echo 'Hello'; $post_data = file_get_contents('php://input'); echo "<div> POST BODY <br>".$post_data."</div>";
- This reply was modified 4 years, 7 months ago by
jwrbloom.
jwrbloom
ParticipantI saw the groups workaround, and that’s essentially what I’m doing. Great point about using the variables in the email. I can create my own CSV in the email.
Is this another option?
If I send that string of data (realizing they aren’t actually repeatable fields) to a .php, I could effectively add hidden elements to create field and line terminations. Does that sound about right?I guess my question is, can I just get some variation of a var_dump?
- This reply was modified 4 years, 7 months ago by
jwrbloom.
jwrbloom
ParticipantIt had it return all data, limit 10. It didn’t return anything.
Once I get through this process, I’m going to look into converting my queries to mysqli. Not sure about this PDO stuff. I’ll email you the information you asked.
jwrbloom
ParticipantUPDATE code: added this line:
$num_rows = mysql_num_rows($results);
…then put the $num_rows in the IF loop.
I’ve tested with information I know exists in a_players, but it’s still showing $num_rows as NULL.
add_action('quform_post_process_1', function (array $result, Quform_Form $form){ $data = array( 'f_school' => $form->getValue('quform_1_7'), 'f_grade' => $form->getValue('quform_1_5'), 'f_nameFirst' => $form->getValue('quform_1_3'), 'f_nameLast' => $form->getValue('quform_1_4') ); Quform::log($data['f_school']); Quform::log($data['f_grade']); Quform::log($data['f_nameFirst']); Quform::log($data['f_nameLast']); include (ABSPATH ."resources/connection.php"); $query = "SELECT nameFirst,nameLast,grade FROM a_players WHERE nameFirst = '" . $data['f_nameFirst'] ."' and nameLast = '" . $data['f_nameLast'] . "' and grade = '" . $data['f_grade'] ."'"; $results = mysql_query($query); $num_rows = mysql_num_rows($results); Quform::log(mysql_error()); Quform::log(mysql_num_rows()); Quform::log($results['nameFirst']); // while($check = mysql_fetch_assoc($results)) { if (($num_rows) == 0) { "INSERT INTO a_players (school, grade, nameFirst, nameLast) VALUES ('".$data['f_school']."', '".$data['f_grade']. "', '" .$data['f_nameFirst']. "', '" .$data['f_nameLast']."')"; } return $result; }, 10, 2);
jwrbloom
ParticipantSo I added…
Quform::log(mysql_error());
…to my code.
And it came up with this.
[08-Jan-2018 14:26:50 UTC] string(62) “Access denied for user ‘root’@’localhost’ (using password: NO)”Should I added my connection call to this file? I thought it would already be connected to AP since it’s posting to APR table.
- This reply was modified 4 years, 7 months ago by
- AuthorPosts