beans_replace_action

Replace an action.

This function replaces an action registered using beans_add_action() or beans_add_smart_action(). Each optional argument must be set to NULL to keep the orginal value.

While beans_modify_action() will keep the original value registered, this function will overwrite the original action. If the action is reset using beans_reset_action(), the replaced values will be used.

beans_replace_action( string $id, string $hook = null, callback $callback = null, int $priority = null, int $args = null )

Return: (bool) Will always return true.

Parameters

NameTypeRequiredDefaultDescription
$idstringtrue-The action ID.
$hookstringfalsenullThe name of the new action to which the $callback is hooked. Use NULL to keep the original value.
$callbackcallbackfalsenullThe name of the new function you wish to be called. Use NULL to keep the original value.
$priorityintfalsenullThe new priority. Use NULL to keep the original value.
$argsintfalsenullThe new number of arguments the function accepts. Use NULL to keep the original value.

Source

function beans_replace_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) {

	$action = array(
		'hook'     => $hook,
		'callback' => $callback,
		'priority' => $priority,
		'args'     => $args,
	);

	// Set and get the latest replaced.
	$action = _beans_merge_action( $id, array_filter( $action ), 'replaced' );

	// Set and get the latest added.
	$action = _beans_merge_action( $id, $action, 'added' );

	return beans_modify_action( $id, $hook, $callback, $priority, $args );

}