Elementor’s PHP hooks, both filter hooks and action hooks

Elementor, like many WordPress themes and plugins, makes use of actions and filters to allow you to customize its functionality.

  • Actions: These are hooks that allow you to insert your own code at specific points in Elementor’s code. For example, you can use an action hook to add a custom field to the Elementor’s editor, or to add a custom CSS class to an element.
  • Filters: These are hooks that allow you to modify data before it is used by Elementor. For example, you can use a filter hook to change the label of a button, or to modify the content of a post before it is displayed.

 

For Using these hooks you will need to have some knowledge of how to write your own functions in PHP language and then use them with the hooks.

Here is an example of how you can use an action hook:

// Create a custom function
function my_custom_action() {
    // Your code here
}
// Use the add_action() function to connect your custom function to the hook
add_action( 'elementor/element/before_render', 'my_custom_action' );

And here is an example of how you can use a filter hook:

// Create a custom function
function my_custom_filter( $value ) {
    // Your code here
    return $value;
}
// Use the add_filter() function to connect your custom function to the hook
add_filter( 'elementor/widget/render_content', 'my_custom_filter' );

Note that for both hooks, the first parameter is the name of the hook you want to use, and the second parameter is the name of the custom function you have created.

Also, for filter hooks it’s important to know that the function that you use to filter must have at least one parameter to receive the value you are trying to filter and return it modified, or even multiple parameters, depending on the hook.

There are a lot of filter and action hooks available in Elementor and lot of them are used in different ways to customize the functionality. You can check their documentation to understand the function and parameters of hooks.