WP_Error::copy_errors( WP_Error $from, WP_Error $to )

In this article

Copies errors from one WP_Error instance to another.

Parameters

$fromWP_Errorrequired
The WP_Error to copy from.
$toWP_Errorrequired
The WP_Error to copy to.

Source

protected static function copy_errors( WP_Error $from, WP_Error $to ) {
	foreach ( $from->get_error_codes() as $code ) {
		foreach ( $from->get_error_messages( $code ) as $error_message ) {
			$to->add( $code, $error_message );
		}

		foreach ( $from->get_all_error_data( $code ) as $data ) {
			$to->add_data( $data, $code );
		}
	}
}

Changelog

VersionDescription
5.6.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.