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

In this article

Initializes the error.

Description

If $code is empty, the other parameters will be ignored.
When $code is not empty, $message will be used even if it is empty. The $data parameter will be used only if it is not empty.

Though the class is constructed with a single error code and message, multiple codes can be added using the add() method.

Parameters

$codestring|intoptional
Error code.

Default:''

$messagestringoptional
Error message.

Default:''

$datamixedoptional
Error data.

Default:''

Source

public function __construct( $code = '', $message = '', $data = '' ) {
	if ( empty( $code ) ) {
		return;
	}

	$this->add( $code, $message, $data );
}

Changelog

VersionDescription
2.1.0Introduced.

User Contributed Notes

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