WP_Error::get_error_message()publicWP 2.1.0

Gets a single error message.

This will get the first message available for the code. If no code is given then the first code available will be used.

Method of the class: WP_Error{}

No Hooks.

Return

String. The error message.

Usage

$WP_Error = new WP_Error();
$WP_Error->get_error_message( $code );
$code(string|int)
Error code to retrieve message.
Default: ''

Changelog

Since 2.1.0 Introduced.

WP_Error::get_error_message() code WP 6.1.1

public function get_error_message( $code = '' ) {
	if ( empty( $code ) ) {
		$code = $this->get_error_code();
	}
	$messages = $this->get_error_messages( $code );
	if ( empty( $messages ) ) {
		return '';
	}
	return $messages[0];
}