• Resolved phpbot

    (@phpbot)


    Getting those errors in debug.log

    [29-Nov-2022 12:31:17 UTC] PHP Warning:  Attempt to read property "user_email" on bool in /var/www/html/wp-content/plugins/acf-extended/includes/modules/forms-action-user.php on line 342
    [29-Nov-2022 12:31:17 UTC] PHP Warning:  Attempt to read property "user_email" on bool in /var/www/html/wp-content/plugins/acf-extended/includes/modules/forms-action-user.php on line 344

    When I add a

    error_log("$target: $user_email !== {$target_user->user_email}");`

    On line 344 of includes/modules/forms-action-user.php I got:

    [29-Nov-2022 12:31:17 UTC] : [email protected] !==

    Seems like $target is falsy and therefore comparing fails, which results in wrong validation messages.

    PHP 8.0.25
    WP 6.1.1
    ACFE 0.8.8.10

    Had to rollback to 0.8.8.7, since 0.8.8.8 introduced the built-in user validation, which is causing the shown errors.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    It looks like the “Target” user in your “Update User Action” doesn’t correctly return an ID. Can you please show what is in that setting in your User Action Form UI?

    I’ll add a control in the next patch to make sure the target is correct before processing the validation.

    Have a nice day!

    Regards.

    Thread Starter phpbot

    (@phpbot)

    Hey

    Thanks a lot for the fast response

    Can you please share a screenshot which part of the UI / which setting you are talking about?

    Searching for a target UI element, but can’t find one. ??

    Here is the first settings screen, if this already includes what you asked for?

    https://gofile.io/d/ps1VB4

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Sure! In the “Save” tab of the “User Action”, the setting is called “Target”. See screenshot.

    If the setting is set to “Current User” (like in the screenshot), then you have to be sure that the form is displayed to logged-in visitors only. Otherwise, it will try to update the user ID 0 which doesn’t exists, and fail.

    Regards.

    Thread Starter phpbot

    (@phpbot)

    Ah okay got it.

    In this case we are using a GET param of the viewed page ?foo[user_id]=123, which translated into ACFE like:

    {request:foo:user_id}

    I can confirm it is working, since saving and loading works without any problems.

    Only the email validation is failing, both for create and update forms.

    Best

    • This reply was modified 1 year, 12 months ago by phpbot.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the details!

    The issue come from that Template Tag. While using {request} works for basic Save Target and Loading Source settings, it doesn’t work for Ajax Validation because the GET parameters are not passed to the ajax request. This is why the builtin User Validation fails.

    I would recommend to pass your user_id to the form during the form initialization, and use the {form:user_id} Template Tag in the Save/Load UI settings instead. Here is a usage example:

    acfe_form(array(
        'name'    => 'my-form',
        'user_id' => $_GET['foo']['user_id']
    ));

    You’ll find a detailed example in this guide: Passing Data to a Form.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter phpbot

    (@phpbot)

    Got it, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘User email validation broken’ is closed to new replies.