Cannot access offset of type string on string in user-edit.php on line 552

[ad_1]

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.

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 hours, 1 minute ago by threadi.

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);

...

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.projectdmc.org/reference/functions/delete_user_meta/ if you want to proceed in this way.

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

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer