Sergei Basharov
Sergei Basharov

Reputation: 53850

Object of class WP_Error could not be converted to string

I create a subdomain in Wordpress MU and then when I go to that subdomain, I get this error:

Catchable fatal error: Object of class WP_Error could not be converted 
to string in /home/pahouse1/public_html/wp-content/mu-plugins/lifetime
/syncronize.php on line 450**

Did anyone face the same issue? What can I do about this?

Upvotes: 0

Views: 4715

Answers (1)

Rene Terstegen
Rene Terstegen

Reputation: 8046

A bit more code would be nice.

Normally this means you are trying to print an object. Something like this:

$a = new ObjectA();
echo $a;

Which is not possible because, as the error says, a non-string variable (in this case a class object) couldn't be converted to a string.

You can fix this by writing a magic method __toString() for that class.

Full information can be found at http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring.

Upvotes: 3

Related Questions