$data is being passed as a string rather than an array
-
Hello,
I am getting the following PHP error
I am getting the following PHP error
[23-Aug-2024 10:58:55 UTC] PHP Warning: foreach() argument must be of type array|object, string given in /home/nuclearmed/htdocs/nuclearmed.org/wp-content/plugins/quiz-master-next/php/template-variables.php on line 530This is the content of the template-variables.php from line 504 to 536
/**- Returns user values for all contact fields
* - @since 5.0.0
- @return string The HTML for the content
*/
function qsm_all_contact_fields_variable( $content, $results ) {
global $mlwQuizMasterNext;
$contact_form = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( ‘contact_form’ ); $return = ”;
if ( isset( $results[‘contact’] ) && ( is_array( $results[‘contact’] ) || is_object( $results[‘contact’] ) ) ) {
foreach ( $results[‘contact’] as $results_contact ) {
$options = qsm_get_options_of_contact_fields($contact_form, $results_contact[‘label’], $results_contact[‘type’] );
$isRadioOrSelect = in_array($results_contact[‘type’], [ ‘radio’, ‘select’ ], true);
$hasOptions = ! empty(trim($options));if ( ($isRadioOrSelect && $hasOptions) || ! $isRadioOrSelect ) { $return .= $results_contact['label'] . ': ' . $results_contact['value'] . '<br>'; } }}
$content = str_replace( ‘%CONTACT_ALL%’, $return, $content );
return $content;
}
function qsm_get_options_of_contact_fields( $data, $label, $type ) {
foreach ( $data as $item ) {
if ( $item[‘label’] === $label && $item[‘type’] === $type ) {
return $item[‘options’];
}
}
return null; // Option not found
}
Can you please help me fix it?
Best regards,
Nasser
The page I need help with: [log in to see the link]
- Returns user values for all contact fields
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘$data is being passed as a string rather than an array’ is closed to new replies.