WP_Error::add_data( mixed $data, string|int $code =  )

In this article

Adds data to an error with the given code.

Parameters

$datamixedrequired
Error data.
$codestring|intoptional
Error code.

Default:''

Source

public function add_data( $data, $code = '' ) {
	if ( empty( $code ) ) {
		$code = $this->get_error_code();
	}

	if ( isset( $this->error_data[ $code ] ) ) {
		$this->additional_data[ $code ][] = $this->error_data[ $code ];
	}

	$this->error_data[ $code ] = $data;
}

Changelog

VersionDescription
5.6.0Errors can now contain more than one item of error data. WP_Error::$additional_data.
2.1.0Introduced.

User Contributed Notes

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