Error on redirect

  • Profile Image
    Asked on October 27, 2020 at 11:21 AM

    I am having an issue. I have condition on my form that people get redirected to a website if they dont answer a question the way i want. Currently the page they are being redirected to is showing an error. Its only when they are directed there. If you go to the link it works.

    Here is the error - Warning: trim() expects parameter 1 to be string, array given in /home4/alexj/public_html/ on line 735

  • Profile Image
    Answered on October 27, 2020 at 01:26 PM

    Hello there,

    Thank you for reaching Support.

    Looks like you're sending POST data 1  to the website after submission.

    To fix this, you can simply disable the option to send POST data 1  from your form settings, if you don't intend to process the submission data programmatically.

    Otherwise, I don't know what your code looks like on your website, but based on the warning message "trim() expects parameter 1 to be string, array given in...", trim() is being applied on an array.

    If you really need to use trim(), you can use the is_array() function on your conditional statement to check if a variable is an array, and use array_map('trim', $array) if it is.

    I'm no PHP expert but the code may look something like so:

    $output = (is_array($input)) ? array_map('trim', $input) : trim($input);

    Or, you can simply disable WordPress site's debug mode. 2

    Hope that helps. Let us know if you have any questions or if you need further assistance.

     Related Guides:

    1. How to Post Submission Data to Thank You Page
    2. Debugging in WordPress