Filter
uncanny-automator
automator_hubspot_options_get_lists
Filters the available HubSpot lists for selection within the Automator integration.
add_filter( 'automator_hubspot_options_get_lists', $callback, 10, 1 );
Description
Filters the HubSpot list options before they are returned via AJAX. Developers can modify the array of lists to exclude specific ones, add custom entries, or alter existing data. This hook fires within the `get_list_options_ajax` method, allowing real-time manipulation of available HubSpot lists.
Usage
add_filter( 'automator_hubspot_options_get_lists', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter contains the array of HubSpot lists to be filtered.
Return Value
The filtered value.
Examples
add_filter(
'automator_hubspot_options_get_lists',
function ( $lists ) {
// Example: Filter out lists that contain the word "Internal" from the results.
// This could be useful if you want to prevent users from selecting internal-only lists.
if ( ! is_array( $lists ) ) {
return $lists; // Return original if not an array
}
$filtered_lists = array();
foreach ( $lists as $list_id => $list_name ) {
if ( strpos( $list_name, 'Internal' ) === false ) {
$filtered_lists[ $list_id ] = $list_name;
}
}
return $filtered_lists;
},
10, // Priority
1 // Accepted args (only $lists is passed to the callback)
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/hubspot/helpers/hubspot-app-helpers.php:92
public function get_list_options_ajax() {
Automator()->utilities->verify_nonce();
$options = apply_filters(
'automator_hubspot_options_get_lists',
$this->get_lists( $this->is_ajax_refresh() )
);
$this->ajax_success( $options );
}