Hi,
After updating to the latest version of wpDiscuz (updated on my site two days ago), I encountered a fatal PHP error:
Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, WP_User given in /wp-includes/class-wp-user.php:218
After some debugging, I tracked it down to this line in your plugin:
get_user_by("email", $idOrEmail); // in WpdiscuzHelper.php, line 1116
In some cases, $idOrEmail is actually a WP_User object, which causes get_user_by() to fail since it expects a string, not an object.
🔧 Temporary Fix
I modified the getUserNameAndEmail() function inside class.WpdiscuzHelper.php to properly handle the case where $idOrEmail is a WP_User object:
} elseif ($idOrEmail instanceof WP_User) {
$nameAndEmail = [
"name" => $idOrEmail->display_name,
"email" => $idOrEmail->user_email,
"isUser" => 1,
"user_id" => $idOrEmail->ID,
];
}
This resolved the issue completely.
Just wanted to report this so it can be patched in the next update. Thanks for your great work and support!
Hi,
We'll check and get back to you ASAP.
I have the same fatal error on the site when trying to create or edit a post.
The issue is fixed, please update the wpDiscuz to the latest version (v. 7.6.32), clear all kinds of caches and check again.