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,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
Block a user