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,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