WordPress Embedded Form: URL prepopulation giving warning

  • Profile Image
    7Aspire
    Asked on September 14, 2018 at 08:06 AM

    For a long time I have used my forms as standalone forms, and have always sent pre-populated form links to my clients; here is a typical link sent for my Arrival Form:

    https://eu.jotform.com/71102315984351?&arrivalDate135=Thursday+11+October+2018&type=Main&name[first]=John&name[last]=Doe 

    This has always worked fine.

    However I am now trying to migrate my form into my Wordpress site.  I followed the guide embedding this script

    <script type="text/javascript" src="https://form.jotformeu.com/jsform/71102315984351"></script>

    into the text area of the page concerned.

    If I send my client a link to the page without pre-population, there are no problems loading the page; see

    https://7aspireholidayapartment.com/arrival/

    However, if I try to pre-populate the form, the form correctly loads and pre-populates, but a Wordpress warning appears.

    Here is the link to the pre-populated form:

    https://7aspireholidayapartment.com/arrival/?arrivalDate135=Thursday+11+October+2018&type=Main&name[first]=John&name[last]=Doe

    and here it the text of the Wordpress warning message that appears when pre-population is used:

    Warning: trim() expects parameter 1 to be string, array given in /home/c7aspire/public_html/wp-includes/class-wp-query.php on line 736

    What am I doing wrong, or what do I need to change?

    Many thanks
    David Howes

  • Profile Image
    daisy
    Answered on September 14, 2018 at 10:00 AM

    Please try to re-embed the form with iFrame code instead of source code. Because, when you embed the form with source code sometimes there are conflicts with website's and form's JavaScript codes.

    https://www.jotform.com/help/148-Getting-the-Form-iFrame-Code

    Also, I searched the error that you get and maybe the error is caused by the Wordpress and it is not related the form.

    Please let us know if the problem persists.

  • Profile Image
    7Aspire
    Answered on September 14, 2018 at 11:13 AM

    Hi Daisy

    I replaced the Wordpress.org-specific script provided on the Publish tabs with the generic iframe code you suggested.

    Both codes loaded the form in exactly the same way.

    A page without pre-population loads and runs correctly with both methods of embedding.

    Clearly there is no issue either with the Wordpress page or the simple-embedded form.

    The issue I have concerns pre-population.  Whilst the form can be pre-populated with both the eu.jotform.com hosted form and the Wordpress page, the Wordpress page throws up the error message described above.  Clearly there is something in the pre-population script of the URL that is conflicting with Wordpress.

    My question is, is this a known conflict with pre-population scripts, am I not using pre-population correctly, has any other Wordpress/Jotform user had the same problem, has any sort of workaround been devised?

    Regards
    David

  • Profile Image
    Mike
    Answered on September 14, 2018 at 12:05 PM

    I am not sure if the form pre-population by URL parameters is compatible with the wordpress websites. I will do the wordpress install and get back to you later after some tests.

  • Profile Image
    Mike
    Answered on September 14, 2018 at 04:42 PM

    This is not a known JotForm issue. It seems to be happening when you pass the name[first], so PHP reads this as an array and wordpress throws a warning for some reason.

    The warning is most likely displayed due to enabled debug mode in your wordpress website. If your site is functioning correctly, you may hide the warning by turning off the wordpress debug mode. You can do this by changing WP_DEBUG to false in the wp-config.php file.

    define('WP_DEBUG', false);

    Alternatively, you may also check the issue with some experienced wordpress developer.

  • Profile Image
    7Aspire
    Answered on September 14, 2018 at 06:11 PM

    Hi Mike

    Thanks for the update. My wp-config.php file already has the line

    define('WP_DEBUG', false);

    so it's not that.

    The pre-population string clearly doesn't like name[first]= or name[last]= - if either or both of these fields is included in the URL parameters then the warning message is displayed - the URL will happily load with the arrivalDate135= and type= parameters.

    I'll try redefining the form fields to something other than name[] and see if that solves the problem.

  • Profile Image
    Mike
    Answered on September 14, 2018 at 10:59 PM

    If the WP_DEBUG set to false does not hide the warning, it might be caused by the PHP settings. It should be still possible to hide the warning. You may try adding a few more configuration lines to the wp-config.php file, please take a look at:

    WordPress. How to hide PHP warnings and notices

    Thank you.