WordPress at a glance

__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.000001s = speed of light | 50000 times = 0.00s = 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;

Code of __return_false: wp-includes/functions.php VER 4.9.8

function __return_false() {
	return false;

Related Functions

From tag: __return (helper functions)

More from category: Helper Functions

No comments
    Hello, !     Log In . Register