WP_Error could not be converted to string

There are few problems with your code. First of all, let’s see at wpmu_create_blog function: wpmu_create_blog( string $domain, string $path, string $title, int $user_id, array $meta = array(), int $network_id = 1 ) So you use it incorrectly. It’s 5th argument is $meta and you put $network_id in there… Another problem is that this function … Read more

To stylize WP_Error messages or not?

Personally I prefer to put all errors in a debug.log file using error_log and it would be readable enough as it includes break lines automatically. I think not all the errors should be visible for clients. In case that I need to show an error to the user, I check the error type and I … Read more

Cannot use object of type WP_Error

What’s $genres? I don’t see it defined anywhere. And wp_insert_term() may return an error, so make sure to check if it is an error. So instead of simply doing return wp_insert_term($name,$tax)[“term_id”], you could do something like this: $data = wp_insert_term( $name, $tax ); if ( ! is_wp_error( $data ) ) { return $data[‘term_id’]; }

How to group multiple wp_errors together?

You can retrieve all of the message of the same code with the get_error_messages() method (hacked from some code in the Codex): function doer_of_stuff() { $err = new WP_Error( ‘broke’, “I’ve fallen and can’t get up 1”); $err->add(‘broke’, “I’ve fallen and can’t get up 2”); $err->add(‘borken’, “not this one”); $err->add(‘borken’, “not this one”); $err->add(‘broke’, “I’ve … Read more

tech