remove_action( string $tag, callable $function_to_remove, int $priority = 10 )

Removes a function from a specified action hook.


Description Description

This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.


Parameters Parameters

$tag

(string) (Required) The action hook to which the function to be removed is hooked.

$function_to_remove

(callable) (Required) The name of the function which should be removed.

$priority

(int) (Optional) The priority of the function.

Default value: 10


Top ↑

Return Return

(bool) Whether the function is removed.


Top ↑

Source Source

File: wp-includes/plugin.php

function remove_action( $tag, $function_to_remove, $priority = 10 ) {
	return remove_filter( $tag, $function_to_remove, $priority );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note content
    Contributed by Codex

    This function is identical to the remove_filter() function.

     <?php remove_action( $tag, $function_to_remove, $priority ); ?> 
    

    If an action has been added from within a class, for example by a plugin, removing it will require accessing the class variable.

    global $my_class;
    remove_action( 'the_content', array( $my_class, 'class_filter_function' ) );
    

    It is also worth noting that you may need to prioritise the removal of the action to a hook that occurs after the action is added. You cannot successfully remove the action before it has been added.

You must log in before being able to contribute a note or feedback.