• Resolved evalast

    (@evalast)


    Using latest wordpress version and getting

    Uncaught TypeError: Cannot access offset of type string on string in /home/duducloud/webapps/abctesttest_shop/wp-admin/user-edit.php:552 Stack trace: #0 /home/duducloud/webapps/abctesttest_shop/wp-admin/profile.php(18): require_once() #1 {main} thrown in /home/duducloud/webapps/abctesttest_shop/wp-admin/user-edit.php on line 552


    Deactivated all plugins and used default wp theme – still seeing the error.

    Edited the mentioned file – user-edit.php and

    replaced

    if ( $new_email && $new_email[‘newemail’] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :

    with

    if ( is_array( $new_email ) && isset( $new_email[‘newemail’] ) && $new_email[‘newemail’] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :

    which fixed the issue.

    Can you pls let me know if it is a core wp issue. Im stuck atm. thx

    • This topic was modified 4 months ago by evalast.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter evalast

    (@evalast)

    Seems like this happens if there is a pending email change reqest for the admin email address? i clicked cancel, roled back changes of the user-edit.php file and now it works.

    threadi

    (@threadi)

    That looks more like an error in the content. The line mentioned is about the value for a new e-mail from a user meta field in the database. This must always be an array – but it is not in your case.

    It is difficult to understand why this has happened. My guess would be that a plugin has saved the value incorrectly. Deactivating the plugin does not solve the content problem in the database, which is why it happens even after deactivating the plugins.

    To solve it, you need to change the value in the database back to something WordPress expects. So either delete it or turn it into an array. I see 2 ways to do this:

    a) You save a new email for the affected account. This should already change the value.
    b) You go to phpmyadmin and search in the database table usermeta (is written with an individual prefix) for the relevant user_id and the field “_new_email” and delete only this data record.

    And another tip: never change core files. This will make it impossible to help you as it is unclear what else has been changed.

    • This reply was modified 4 months ago by threadi.
    Thread Starter evalast

    (@evalast)

    thx for your answer – i changed core files just temporarily. i have a custom frontend handler to let user change their email. value of $_POST[’email’] is just plain text. Using it this way works fine for all roles except the admin user role. No errors in logs and no erros in backend.

    To fix the issue i do not allow the admin role to change the email anymore. I tried saving the values as arrays like

    update_user_meta($user_id, ‘_new_email’, array(’email’ => $new_email));
    update_user_meta($user_id, ‘_email_confirm_key’, array(‘key’ => $confirmation_key));

    for customer role but got errors. this version (strings) works fine as mentioned before – Is this ok:

    ...

    $new_email = sanitize_email($_POST['email']);

    $current_email = $current_user->user_email;

    if ($new_email !== $current_email) {

    // Generate a confirmation key
    $confirmation_key = wp_generate_password(20, false);
    update_user_meta($user_id, '_new_email', $new_email);
    update_user_meta($user_id, '_email_confirm_key', $confirmation_key);

    ...
    threadi

    (@threadi)

    The path you have taken is not one that I have described above. It is also unclear to me in what context you are executing this custom code. I would recommend that you delete the entry via https://developer.www.ads-software.com/reference/functions/delete_user_meta/ if you want to proceed in this way.

    Thread Starter evalast

    (@evalast)

    thx again – im closing it. Just tested my code and it works fine atm.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.