How do I display my stored proc results called via Functions.php to pag
-
Hi everyone!
I’m pulling my hair out and am feeling super stupid because i can’t get this to work.
I am trying to build a Client database for a non-for-profit. They want search functionality to pull inputted clients data.So i have a basic search page on FirstName and LastName. On submit I call the functions.php where I have a wpdb call to a stored procedure. It returns an array with the correct results. I have no idea how to get these results back to my wordpress page. I’ve simplified it just to return Middle Name for now.
I’ve tried “echo”.. maybe i shouldn’t be using elementor_pro/forms/new_record…
I really appreciate any help you can provide. Here is my function below.
//Client Search
add_action( ‘elementor_pro/forms/new_record’, function( $record, $ajax_handler ) {
//make sure its the Client Seach page$form_name = $record->get_form_settings( ‘form_name’ );
error_log($form_name);
if ( ‘Client_Search’ !== $form_name ) {
return;
}$raw_fields = $record->get( ‘fields’ );
$fields = [];
foreach ( $raw_fields as $id => $field ) {
$fields[ $id ] = $field[‘value’];
}$pFirstName = $fields[‘clientSearchFirstName’] ;
$pLastName = $fields[‘clientSearchLastName’];
global $middleName;error_log($pFirstName);
error_log($pLastName);global $wpdb;
$query = “CALL Get_Clients(‘{$pFirstName}’, ‘{$pLastName}’)”;
$result = $wpdb->get_results($query, ARRAY_A);
foreach($result as $row)
{
error_log(“test 3”);
$middleName = $row[‘Middle_Name’];
error_log($middleName);
echo $middleName;
$output = $middleName;
}$ajax_handler->add_response_data( true, $output );
}, 10, 2);`
- The topic ‘How do I display my stored proc results called via Functions.php to pag’ is closed to new replies.