$error = new WP_Error( 'missing_value', 'A required value is missing.', array( 'value_name' => 'username' ) ); $data = $error->get_error_data( 'missing_value' );
$error = new WP_Error(); $error->add( 'missing_value', 'A required value is missing.', array( 'value_name' => 'username' ) ); $error->add( 'invalid_value', 'The value entered is invalid.', array( 'value_name' => 'email' ) ); foreach ( $error->get_error_codes() as $code ) { $data = $error->get_error_data( $code ); // Do something with the error data... }The WP_Error class is a part of the WordPress core, which means it is included in the WordPress package.