Get all error messages with get_error_messages().
git-svn-id: https://develop.svn.wordpress.org/trunk@3679 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4bbee1b73c
commit
6f355ce778
|
@ -215,8 +215,7 @@ case 'add-user' :
|
|||
require_once( ABSPATH . WPINC . '/registration-functions.php');
|
||||
$user_id = add_user();
|
||||
if ( is_wp_error( $user_id ) ) {
|
||||
foreach( $user_id->get_error_codes() as $code)
|
||||
foreach( $user_id->get_error_messages($code) as $message )
|
||||
foreach( $user_id->get_error_messages() as $message )
|
||||
echo "$message<br />";
|
||||
exit;
|
||||
} elseif ( !$user_id ) {
|
||||
|
|
|
@ -10,8 +10,7 @@ if ( !$_POST )
|
|||
$errors = edit_user($user_ID);
|
||||
|
||||
if ( is_wp_error( $errors ) ) {
|
||||
foreach( $errors->get_error_codes() as $code)
|
||||
foreach( $errors->get_error_messages($code) as $message )
|
||||
foreach( $errors->get_error_messages() as $message )
|
||||
echo "$message<br />";
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -63,8 +63,7 @@ if (!current_user_can('edit_users'))
|
|||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach( $errors->get_error_codes() as $code)
|
||||
foreach( $errors->get_error_messages($code) as $message )
|
||||
foreach( $errors->get_error_messages() as $message )
|
||||
echo "<li>$message</li>";
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
@ -195,8 +195,7 @@ default:
|
|||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach( $errors->get_error_codes() as $code)
|
||||
foreach( $errors->get_error_messages($code) as $message )
|
||||
foreach ( $errors->get_error_messages() as $message )
|
||||
echo "<li>$message</li>";
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
@ -363,7 +363,16 @@ class WP_Error {
|
|||
return $codes[0];
|
||||
}
|
||||
|
||||
function get_error_messages($code) {
|
||||
function get_error_messages($code = '') {
|
||||
// Return all messages if no code specified.
|
||||
if ( empty($code) ) {
|
||||
$all_messages = array();
|
||||
foreach ( $this->errors as $code => $messages )
|
||||
$all_messages = array_merge($all_messages, $messages);
|
||||
|
||||
return $all_messages;
|
||||
}
|
||||
|
||||
if ( isset($this->errors[$code]) )
|
||||
return $this->errors[$code];
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue