-1

I use WP Customer Reviews on my WordPress site and each time me or one of my users logs in this error message comes up:

Catchable fatal error: Object of class WP_User could not be converted to string in /hermes/bosoraweb097/b2086/ipg.mysite.com1/wp-content/plugins/wp-customer-reviews/wp-customer-reviews.php on line 239

It's causing many users to turn away and not bother logging in. Line 239 of the code is the following:

$this->p->$c = trim(stripslashes($val));

I don't want to edit this code to save damaging any of the WP Customer Reviews. Anyone know how this error can be fixed.

  • Post the surrounding code, please. Have you contacted the plugin's author? Any hacks you make will be overwritten when the plugin updates. It will be best to get a fix written into the plugin. – s_ha_dum Jan 16 '14 at 17:55
  • 2
    Have you checked the plugin's support forum? It sounds like the plugin is trying to treat a WP_User object as a string. What do you get if you (temporarily) add var_dump( $val ); at, say, line 238 in the plugin? – Pat J Jan 16 '14 at 17:55
  • Added that line of code but now this error is coming up each time I log in: Catchable fatal error: Object of class WP_User could not be converted to string in /hermes/bosoraweb097/b2086/ipg.cantchoosecouk1/wp-content/plugins/wp-customer-reviews/wp-customer-reviews.php on line 240 – Joshua Taylor Jan 16 '14 at 19:04
  • Also, I have contacted the plugin author and asked this same question on the support forum but still had no reply. – Joshua Taylor Jan 16 '14 at 19:10
  • Please paste the results -- if any -- of the var_dump() into your question? (The error you're getting is the same one, just moved down a line, since you've inserted a new line of code.) – Pat J Jan 16 '14 at 19:14
1

Replace that line with the following:

if(!is_object($val) && !is_array($val)){
    $this->p->$c = trim(stripslashes($val));
} else {
    $this->p->$c = $val;
}

This is just a temporary solution so the error will go away. All this does is check the variable to see if it's an object or an array. If it is the variable just gets saved to the correct place. This doesn't fix the root of the problem which is the fact that the user object is attempted to be saved as a string. This may cause other problems.

It is HIGHLY recommended you get in touch with the plugin developer.

  • What other problems would this be causing? And which line of code do I replace with that code? – Joshua Taylor Jan 16 '14 at 19:20
  • The short answer: I don't know. Since you want a quick answer I gave a quick solution. Ultimately you'll need to contact the plugin developer to have them build out a fix for that bug. – MikeNGarrett Jan 16 '14 at 20:04
  • You'll want to replace the line you provided in your question with the lines I provided in my answer, ie 1 line is replaced by 5 lines. – MikeNGarrett Jan 16 '14 at 20:04
  • I tried that code but it didn't seem to work. – Joshua Taylor Jan 16 '14 at 21:45
  • Whoops! I forgot a semicolon. Sorry. Edited. – MikeNGarrett Jan 17 '14 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.