disabled()WP 3.0.0

Compares two given values, and if they are the same, displays disabled = 'disabled' – an attribute for a form input field.

The function is usually used inside the input and textarea fields of the HTML form.

This is one of the four helper functions for forms: checked(), disabled(), selected(), readonly().

No Hooks.



  • Echoes disabled='disabled' if the given values match.
  • If the third parameter is false (default is true) then a string disabled='disabled' or an empty string will be returned.


disabled( $disabled, $current, $display );
$disabled(mixed) (required)
One of the values to compare.
The other value to compare if not just true.
Default: true
Whether to echo or just return the string.
Default: true



#1 Demonstration of the usage

Let's say we have a group of radio form fields. One of the fields is already involved in the options and, therefore, this field cannot be selected. In this case, we can add the disabled attribute to this field. This example demonstrates how to do it conveniently with this function.

Suppose the value of the option field is "red".

<input type="radio" name="option" value="red" <?php disabled( $_POST['option'], 'red' ) ?> > Red
<input type="radio" name="option" value="green" <?php disabled( $_POST['option'], 'green' ) ?> > Green
<input type="radio" name="option" value="blue" <?php disabled( $_POST['option'], 'blue' ) ?> > Blue


<input type="radio" name="option" value="red" disabled='disabled' > Red
<input type="radio" name="option" value="green"> Green
<input type="radio" name="option" value="blue"> Blue


Since 3.0.0 Introduced.

disabled() code WP 6.5.3

function disabled( $disabled, $current = true, $display = true ) {
	return __checked_selected_helper( $disabled, $current, $display, 'disabled' );