Home Forums Plugin Support WP User Frontend Pro Bug Report: Empty form fields are not in $_POST = error in render-form.php

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7937

    lfd
    Participant
    Post count: 3

    WP User Frontend Pro (v2.1.7)
    WordPress (v3.6)

    Summary: PHP Notice due to Undefined index stalls AJAX.

    Where: function prepare_meta_fields() in class/render-form.php

    To reproduce:

    • Create a new Registration Form.
    • Add the First Name field and make it required.
    • Add a checkbox field named ‘my_checkbox' and make it NOT required.
    • Add any three options to the checkbox field.
    • Publish the form.
    • Place the Edit Profile shortcode on a page.
    • Visit the page with the Edit Profile form.
    • Submit the form without checking any options for the checkbox field.

    Error:

    [Sun Sep 08 15:49:40 2013] [error] [client 127.0.0.1] PHP Notice: Undefined index: my_checkbox in /Users/bpk/Sites/local.wordpress.dev/public/wp-content/plugins/wp-user-frontend-pro/class/render-form.php on line 211, referer: http://local.wordpress.dev/wpuf-profile-form-field-tests/?msg=profile_update

    [Sun Sep 08 15:49:40 2013] [error] [client 127.0.0.1] PHP Notice: Undefined index: my_checkbox in /Users/bpk/Sites/local.wordpress.dev/public/wp-content/plugins/wp-user-frontend-pro/class/render-form.php on line 214, referer: http://local.wordpress.dev/wpuf-profile-form-field-tests/?msg=profile_update

    Details:

    If a checkbox field is NOT required, the Edit Profile form can be submitted without any selected (checked) options. With no options checked, $_POST does not include this checkbox field as an index in the array.

    In class/render-form.php, the prepare_meta_fields function loops over ALL the fields defined in the form, but on Line 211 we get an error because the checkbox field name is not in $_POST.

    $_POST[$value['name']]
    $_POST['my_checkbox'] is not set.

    #7941

    lfd
    Participant
    Post count: 3

    Sorry, I shouldn't have noted that this only stalls AJAX when WP_DEBUG is true.

    #7943

    Tareq Hasan
    Keymaster
    Post count: 2831

    Hello Brian, thats a great bug report. Not that the bug is great, but the report is ๐Ÿ™‚

    Obviously that'll only work when WP_DEBUG is true, but I'll fix it in the next version. Thanks for the report.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Bug Report: Empty form fields are not in $_POST = error in render-form.php’ is closed to new replies.