How can we pass the email from our website to the form embedded with js embed code?

  • Profile Image
    Asked on June 19, 2015 at 12:03 PM

    Hi there,

    Is it possible to pass a value from my Main website onto the embedded form.

    layout of site:

    Main Website -> Embed form using  <script type="text/javascript" src="//"></script>

    I would like to pass through users email address from the main website onto the embedded form.

    How would I do that using the embedded code above?

  • Profile Image
    Answered on June 19, 2015 at 12:35 PM

    I can do it by embedding the full source but its causing css errors on my wordpress website. I refuse to use iframe option.

  • Profile Image
    Answered on June 19, 2015 at 01:24 PM

    You can also do it with any other embed codes (iframe, js embed) the way to do it is to just set it all up for URL prepopulating.

    For example, you can see it in action like so:

    Now when we turn it into the js embed code, we just change the URL to include the parameter that we need, like so:

    <script type="text/javascript" src="//"></script>

    Now the tricky part here is the part where you are passing the email value, because you must add it over php or js code, depending on what you prefer and have available.

    Unfortunately we can not help with such custom solutions, but could help you with few pointers if needed so I advise hiring a developer (again depending on what you need to do exactly).

    I would recommend using the php code if possible and then just pass that value to email parameter, for example:

    $email = '';
    $email = code_to_get_email_from_db(); //you would need to write this function

    <script type="text/javascript" src="//<?php echo $email; ?>"></script>

    Do let us know how it goes.

  • Profile Image
    Answered on June 19, 2015 at 01:42 PM

    you are a star!!!! :)

    used the following code on wordpress:

    <script type="text/javascript" src="<?php $current_user = wp_get_current_user(); echo $current_user->user_email ?>"></script>