__return_false()WP 3.0.0

Simply returns false. Helper function of WordPress.

Used in filters when you want to specify a function that always returns false.

All such helper functions:
__return_false() — returns false.
__return_true() — returns true.
__return_empty_array() — returns an empty: array().
__return_zero() — returns the number 0.
__return_null() — returns NULL.
__return_empty_string() — returns an empty string: ''.

1 time — 0.000001 sec (speed of light) | 50000 times — 0.00 sec (speed of light) | PHP 7.1.11, WP 4.9.7

No Hooks.







#1 Return false in the filter

Let's say we have a filter 'show_admin_bar' and we need to return false in the value of this filter. To do this, we can write a specific function or use the auxiliary function __return_false():

add_filter( 'show_admin_bar', '__return_false' );

The same result can be reached with following codes:

// with ananimous function (php 5.3+)
add_filter( 'show_admin_bar', function(){ return false; } );

// or so, with register finction in php
add_filter( 'show_admin_bar', 'my_return_function' );
function my_return_function(){
	return false;



Since 3.0.0 Introduced.

__return_false() code WP 6.5.3

function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
	return false;