In Easy Digital Downloads I needed to add my own CSS classes to various error messages such as the Error: Please enter your first name that displays at checkout.

This is very useful when you already have CSS classes setup for alert messages. I usually apply CSS classes of “alert” and “error” to an error message, “alert” and “success” for a success message, or “alert” and “notice” for a notice message. Not being able to add my own classes means creating a whole bunch of unnecessary styling.

Thankfully I made a request on the EDD GitHub account and this feature was introduced in EDD 1.4.1. To filter the edd_print_errors() function and add your own CSS classes, you can now do the following:

function andrew_edd_filter_edd_error_class() { 
	$classes = array( 
		'edd_errors', // required

	return $classes; 
add_filter( 'edd_error_class', 'andrew_edd_filter_edd_error_class' );

Make sure you leave edd_errors in the array or when ajax is enabled, your error messages will start to repeat when the purchase button is clicked. This is because the edd-ajax.js file requires the edd_errors CSS class so it can remove the error messages each time the purchase button is clicked, and the form processes the validation.