• I’ve got quite a few error_log entries for the following for a site I’m helping manage/support:

    [13-Feb-2021 16:39:01 UTC] PHP Warning: Invalid argument supplied for foreach() in public_html/wp-content/plugins/formlift/modules/form/submit.php on line 146

    Relevant code:

    $data = $FormLiftUser->get_user_data(‘form_data’ );

    ?>
    <p>Please wait…</p>
    <form id=”formlift” method=”post” action=”<?php echo $packet[‘url’]; ?>”>
    <input type=”hidden” name=”inf_form_xid” value=”<?php echo $packet[‘xid’];?>” />
    <input type=”hidden” name=”inf_form_name” value=”<?php echo $packet[‘name’];?>” />
    <input type=”hidden” name=”infusionsoft_version” value=”<?php echo $packet[‘version’];?>” />
    <input type=”hidden” name=”timeZone” value=”<?php echo sanitize_text_field($_POST[‘timeZone’]);?>” />
    <?php
    foreach ( $data as $name => $value ):
    ?>
    <input type=”hidden” name=”<?php echo $name;?>” value=”<?php echo $value;?>” />
    <?php
    endforeach;
    ?>
    </form> $data = $FormLiftUser->get_user_data(‘form_data’ );

    ?>
    <p>Please wait…</p>
    <form id=”formlift” method=”post” action=”<?php echo $packet[‘url’]; ?>”>
    <input type=”hidden” name=”inf_form_xid” value=”<?php echo $packet[‘xid’];?>” />
    <input type=”hidden” name=”inf_form_name” value=”<?php echo $packet[‘name’];?>” />
    <input type=”hidden” name=”infusionsoft_version” value=”<?php echo $packet[‘version’];?>” />
    <input type=”hidden” name=”timeZone” value=”<?php echo sanitize_text_field($_POST[‘timeZone’]);?>” />
    <?php
    foreach ( $data as $name => $value ):
    ?>
    <input type=”hidden” name=”<?php echo $name;?>” value=”<?php echo $value;?>” />
    <?php
    endforeach;
    ?>
    </form>

    It seems like $data is probably returning $null or such, so probably should wrap the foreach() inside an “if( is_array( $data ) ){}” block, maybe?

    Jason

  • The topic ‘HP Warning: Invalid argument supplied for foreach() in submit.php on line 146’ is closed to new replies.