The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Fatal error when pa...
 
Share:
Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

Bug [Solved] Fatal error when passing WP_User to getUser_by(), introduced in recent update

7 Posts
4 Users
3 Reactions
216 Views
Posts: 3
Topic starter
(@omriamos)
Active Member
Joined: 5 years ago

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!

6 Replies
Asti
Posts: 8075
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 years ago

Hi,

We'll check and get back to you ASAP. 

Reply
Posts: 2
(@nubchenkon)
New Member
Joined: 2 months ago

I have the same fatal error on the site when trying to create or edit a post.

Reply
Posts: 14
(@tensionmouse)
Eminent Member
Joined: 4 years ago

Same issue here, fatal error when attempting to create or edit a post. Is there a way to move back to v7.6.30 in the meantime?

 

Screenshot 2025 06 24 at 9.12.50 AM
Reply
Posts: 14
(@tensionmouse)
Eminent Member
Joined: 4 years ago

Thanks @omriamos for the fix, confirming it works!

Reply
Asti
Posts: 8075
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 years ago

Hi @tensionmouse, @nubchenkon

The issue is fixed, please update the wpDiscuz to the latest version (v. 7.6.32), clear all kinds of caches and check again. 

Reply
1 Reply
(@nubchenkon)
Joined: 2 months ago

New Member
Posts: 2

@asti updated, everything works.
Thank you for your promptness.

Reply
Share: