Support » Plugin: cformsII » fill fields via url query string

  • Resolved joshbauguss

    (@joshbaugussnet-1)


    Ok so starting with 14.14, something broke my forms.

    For as long as I’ve used cforms (many years), we have always prefilled some fields by passing the page containing the form a query string.

    ?ListingID=12345

    when I upgrade to 14.14, it stops filling the field. I’m hoping this is a bug because it would be a huge problem if this was an intentional change.

    I tried searching this forum but holy cow does the search suck. I did find someone wanting to prefill for logged in users…I’ve prefilled forms in the past by manually setting $_REQUEST[“ListingID”] = “12345”; before calling the cform. So at least it used to be possible.

Viewing 7 replies - 1 through 7 (of 7 total)
  • joshbauguss

    (@joshbaugussnet-1)

    Forgot to note, 14.13.3 works fine.

    Plugin Author bgermann

    (@bgermann)

    So one intentional change was “remove deprecated API functions my_cforms_logic, my_cforms_filter and my_cforms_ajax_filter”. Do you use any of these?

    joshbauguss

    (@joshbaugussnet-1)

    no i don’t use any of those. I switched to your newer method a while back for post form processing and I’ve never used the other filters.

    I have reverted the few sites I had upgraded back to 14.13.3. So I’m not panicked. I’m heading on vacation for a few days and won’t be able to follow up until later next week.

    here is a cforms 14.13.3 install with zero customizations. straight up unzipped the old cforms2.zip file.

    https://bauguss.net/test-form/?ListingID=12345

    you can see it fills in the value of that first field. (or any field)
    https://bauguss.net/test-form/?ListingID=12345&Email=john@doe.com

    joshbauguss

    (@joshbaugussnet-1)

    I’m back to a normal work routine. Can we try and figure out a solution to this? I’m fairly certain when you removed those deprecated functions, it killed the ability for cforms to autofill fields based on the query string.

    This was a really important feature.

    @joshbaugussnet-1
    i use this decision from ancient cforms’ times to our days :))))
    it is not too clever, but very stable 🙂

    I do it with help of custom fields, example:

    link
    <a href="<?php echo get_permalink('123'); ?>?t=<?php echo $post->ID; ?>">book it</a>

    123 – ID of page with this form:
    for cforms id=1

    <?php 
            $form = cforms2('',''); 
            if ($_GET['t']) {
                query_posts("p=".$_GET['t']);
                if (have_posts()) {
                    the_post();
                    $hotel = htmlspecialchars(get_the_title());
    $room1 = htmlspecialchars(get_post_meta($_GET['t'], 'room1', true));
    $room2 = htmlspecialchars(get_post_meta($_GET['t'], 'room2', true));
    $room3 = htmlspecialchars(get_post_meta($_GET['t'], 'room3', true));
    $room4 = htmlspecialchars(get_post_meta($_GET['t'], 'room4', true));
    $room5 = htmlspecialchars(get_post_meta($_GET['t'], 'room5', true));
    $room6 = htmlspecialchars(get_post_meta($_GET['t'], 'room6', true));
    $room7 = htmlspecialchars(get_post_meta($_GET['t'], 'room7', true));
    $room8 = htmlspecialchars(get_post_meta($_GET['t'], 'room8', true));
    $room9 = htmlspecialchars(get_post_meta($_GET['t'], 'room9', true));
    $room10 = htmlspecialchars(get_post_meta($_GET['t'], 'room10', true));
    $room11 = htmlspecialchars(get_post_meta($_GET['t'], 'room11', true));
    $room12 = htmlspecialchars(get_post_meta($_GET['t'], 'room12', true));
    $room13 = htmlspecialchars(get_post_meta($_GET['t'], 'room13', true));
    $room14 = htmlspecialchars(get_post_meta($_GET['t'], 'room14', true));
                }
            }
            $form = str_replace('%hotel%',$hotel,$form);
    $form = str_replace('%room1%',$room1,$form);
    $form = str_replace('%room2%',$room2,$form);
    $form = str_replace('%room3%',$room3,$form);
    $form = str_replace('%room4%',$room4,$form);
    $form = str_replace('%room5%',$room5,$form);
    $form = str_replace('%room6%',$room6,$form);
    $form = str_replace('%room7%',$room7,$form);
    $form = str_replace('%room8%',$room8,$form);
    $form = str_replace('%room9%',$room9,$form);
    $form = str_replace('%room10%',$room10,$form);
    $form = str_replace('%room11%',$room11,$form);
    $form = str_replace('%room12%',$room12,$form);
    $form = str_replace('%room13%',$room13,$form);
    $form = str_replace('%room14%',$room14,$form);
            echo $form;
    ?>

    and in form settings:
    screenshot

    room1,room2… etc – the meta keys of custom fields.

    maybe it will be helpful

    • This reply was modified 2 years, 7 months ago by Sonika.
    • This reply was modified 2 years, 7 months ago by Sonika.
    • This reply was modified 2 years, 7 months ago by Sonika.
    • This reply was modified 2 years, 7 months ago by Sonika.
    • This reply was modified 2 years, 7 months ago by Sonika.
    joshbauguss

    (@joshbaugussnet-1)

    bgermann, have you had a chance to look into this? 
    sonika’s solution really doesn’t work for me. I shouldn’t be having to make any customizations to have this work when it used to work by default.

    This was a built in feature and should remain so. It can’t be that hard to make sure the default value of an element autofills via the $_REQUEST variable of the same field name.

    I guess in some weird way this was handled by the old default my-functions functionality. Odd but if that was the big change, it must have been done there.

    Plugin Author bgermann

    (@bgermann)

    I have fixed the issue on the development version. It will be included in the next published version.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘fill fields via url query string’ is closed to new replies.