Get all error messages with get_error_messages().
git-svn-id: http://svn.automattic.com/wordpress/trunk@3679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6123ea7eb7
commit
0497d716ad
|
@ -215,9 +215,8 @@ 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 )
|
||||
echo "$message<br />";
|
||||
foreach( $user_id->get_error_messages() as $message )
|
||||
echo "$message<br />";
|
||||
exit;
|
||||
} elseif ( !$user_id ) {
|
||||
die('0');
|
||||
|
|
|
@ -10,9 +10,8 @@ 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 )
|
||||
echo "$message<br />";
|
||||
foreach( $errors->get_error_messages() as $message )
|
||||
echo "$message<br />";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,8 @@ 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 )
|
||||
echo "<li>$message</li>";
|
||||
foreach( $errors->get_error_messages() as $message )
|
||||
echo "<li>$message</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -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