Checking return with WP Error

Not entirely sure what you are asking, but if I understand correctly you want to perform some testing on the return value in order to avoid iterating a WP_Error object and perhaps handle errors in some way. According to the documentation get_terms() will return an array of term objects or false if no objects were … Read more

WP_Error not displaying errors

Actions don’t typically return data, so I doubt you will get this working the way you are trying to. Something like… function cpt_pre_post_publish(){ global $my_error; $my_error = new WP_Error(‘error’, __(‘Error!’ )); } add_action(‘pre_get_posts’, ‘cpt_pre_post_publish’); … should set a variable that you could access in a template file with… global $my_error; var_dump($my_error); It is really not … Read more

How to customize the critical error message?

You can use the wp_php_error_message filter to customise this message: add_filter( ‘wp_php_error_message’, function( $message, $error ) { return ‘My custom message.’; }, 10, 2 ); I haven’t tested to be sure, but I would assume that if the critical error that causes this message happens to be in the code of same theme or plugin … Read more

Unable to show error message using wp_login action

Main problem with your code is that you use wp_login action. The wp_login action hook is triggered when a user logs in by the wp_signon() function. It is the very last action taken in the function, immediately following the wp_set_auth_cookie() call. So first of all – the user is already authenticated and his auth cookie … Read more

Cannot use object of type WP_Error as array

Well, it’s pretty clear, why this problem occurs. Let’s look at wp_insert_term documentation: Return Values (array|WP_Error) The Term ID and Term Taxonomy ID. (Example: array(‘term_id’=>12,’term_taxonomy_id’=>34)) As you can see, on success this function returns array. But… If any error occurs, it will return an object of WP_Error type. So… This Fatal Error occurs, because wp_insert_term … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)