BetterLinks 3.1.7 has 25 actions and 83 filters, read directly from its source code on Nov 17, 2026. The list updates automatically when a new version is released.
How to use these hooks
Actions let you run your own code at a specific moment. Filters let you change a value before the plugin uses it. Put your code in a child theme's functions.php or a code-snippets plugin, never in the plugin's own files, because updates overwrite them.
// Run your own code when BetterLinks fires an action
add_action( 'betterlinks/click/inserted', function( $click_id, $item, $arg3 ) {
// Your code runs here.
}, 10, 3 );
// Change a value BetterLinks is about to use
add_filter( 'betterlinks/protected_term_ids', function( $value ) {
// Change $value here.
return $value;
}, 10, 1 );Parts of a name in {braces} are filled in at runtime (for example a post type or field ID). Choose Example on any hook for a ready-to-edit snippet.
All hooks
-
/** * Term IDs that can never be deleted/renamed. Defaults to the built-in * "Uncategorized" category (ID 1); extensions (e.g. the Pro "Link in Bio" * category) add their own protected IDs here. */ apply_filters( 'betterlinks/protected_term_ids', array( 1 ) ); -
betterlinks_mcp_ai_prompt
filter/** * This filter is documented below. */ apply_filters( 'betterlinks_mcp_ai_prompt', $prompt, false ); -
betterlinks_mcp_client_ip
filter/** * Filter the IP used as the MCP rate-limit bucket key. */ apply_filters( 'betterlinks_mcp_client_ip', $ip ); -
betterlinks_mcp_rate_limit
filter/** * Filter the MCP failed-auth rate limit. */ apply_filters( 'betterlinks_mcp_rate_limit', [ $max, $window ] ); -
/** * Filter the MCP client-registration limit per client IP. */ apply_filters( 'betterlinks_mcp_registration_limit', [ self::DEFAULT_MAX_REGISTRATIONS, self::DEFAULT_LOCKOUT ] ); -
betterlinks/admin/link_item
filter/** * Filters a link item returned to the admin dashboard. BetterLinks Pro adds * custom tracking scripts and broken-link status. */ apply_filters( 'betterlinks/admin/link_item', $item ); -
/** * Filters whether the current user may save a short URL over WordPress content * after confirming it. Return false to keep every collision a hard block. */ apply_filters( 'betterlinks/allow_wp_url_collision_override', $allowed, $error ); -
/** * Filters the columns and joins of the per-link click log query. BetterLinks * Pro adds country and user-agent data. Only simple `alias.column` columns and * `LEFT JOIN {prefix}betterlinks_* alias ON a.col = b.col` joins are accepted. */ apply_filters( 'betterlinks/analytics/individual_clicks_select', $select, array( 'link_id' => $id, 'from' => $from, 'to' => $to ) ); -
/** * Filters per-link click analytics (null = not provided). BetterLinks Pro * supplies them. */ apply_filters( 'betterlinks/analytics/individual_link_clicks', null, $args ); -
/** * Filters an analytics cache key. Extensions that change query results * (BetterLinks Pro IP exclusion) vary the key with their settings. */ apply_filters( 'betterlinks/analytics/transient_key', $key . $transient_key, array( 'prefix' => $key, 'from' => $from, 'to' => $to, 'id' => $id ) ); -
betterlinks/click/country_id
filter/** * Filters the country row ID stored with a click (0 = none). BetterLinks Pro * resolves it from the click's country code and name. */ apply_filters( 'betterlinks/click/country_id', isset( $item['country_id'] ) ? absint( $item['country_id'] ) : 0, $item ); -
betterlinks/click/inserted
action/** * Fires after a click row is stored (redirects, the front-end tracker and * clicks replayed from clicks.json). BetterLinks Pro stores the user agent * here. */ do_action( 'betterlinks/click/inserted', $click_id, $item, (int) current( $betterlinks )['ID'] ); -
/** * Filter — return true to turn the WP-content collision check on. */ apply_filters( 'betterlinks/enable_wp_url_collision_check', false, $short ); -
/** * Fires once the click-tracking script is enqueued, so extensions can enqueue * theirs next to it. */ do_action( 'betterlinks/frontend/app_script_enqueued' ); -
/** * Filters whether the click-tracking script loads on every public page. Use it * when linked text is printed outside post content, blocks and widgets. */ apply_filters( 'betterlinks/frontend/force_load_app_script', false ); -
/** * Filters the href used for a BetterLinks-linked text link in post content. * Defaults to the link's short URL; BetterLinks Pro returns the target URL for * uncloaked links. */ apply_filters( 'betterlinks/frontend/linked_text_href', $short_url, $this->link, $href ); -
betterlinks/global_settings
filter/** * Filters the global BetterLinks settings array. Runs while the plugin file * loads, so listeners must be added before that (BetterLinks Pro adds its * auto-create link settings from its own constructor). */ apply_filters( 'betterlinks/global_settings', $settings ); -
/** * Filters link data for a front-end tracker click before it is recorded. * BetterLinks Pro adds the visitor's country here. */ apply_filters( 'betterlinks/js_analytics_tracking/data', $data ); -
/** * Fires after a link and its owned rows are removed. */ do_action( 'betterlinks/link/after_delete', $ID ); -
/** * Filters the target URL of a link right after it is created. Return a * different URL to rewrite it, or null to keep it (BetterLinks Pro applies * global UTM templates here). */ apply_filters( 'betterlinks/link/auto_target_url', null, $id, $arg ); -
/** * Fires once the click is recorded and the response headers are set, just * before the redirect itself is sent. */ do_action( 'betterlinks/link/dispatch_redirect', $target_url, $data ); -
/** * Filters a click row before it is stored. BetterLinks Pro adds country and * user-agent data. */ apply_filters( 'betterlinks/link/insert_click_arg', $click_data, $data ); -
/** * Filters whether redirects send the X-Redirect-Powered-By header. */ apply_filters( 'betterlinks/link/send_powered_by_header', true, $data ); -
/** * Filters the redirect payload written to links.json and the links cache. */ apply_filters( 'betterlinks/links_json_payload', $formattedArray ); -
/** * Filters whether MCP tools require explicit confirmation before a destructive * or overwriting action. Return false to run them on the first call, as they * did before. */ apply_filters( 'betterlinks/mcp/require_confirmation', true, $action, $input ); -
/** * Filters the setting keys the update-settings tool may write. */ apply_filters( 'betterlinks/mcp/writable_settings', $known ); -
/** * Filters the first path segments that short links may never use. */ apply_filters( 'betterlinks/reserved_wp_paths', $reserved ); -
/** * Filters setting keys whose values the generic sanitizer leaves untouched, * because their owner sanitizes them (BetterLinks Pro: autolink_custom_icon). */ apply_filters( 'betterlinks/sanitize/skip_keys', array( 'customFields' ) ); -
/** * Filter — return true to skip the WP URL collision check entirely. Kept for * sites that already use it; only matters once the check has been enabled via * `betterlinks/enable_wp_url_collision_check`. */ apply_filters( 'betterlinks/skip_wp_url_collision_check', false, $short ); -
/** * Filters the import result messages, with rows extensions claimed through * betterlinks/tools/import_row_bucket and the old => new link ID map. * BetterLinks Pro imports link rotations here. */ apply_filters( 'betterlinks/tools/import_process_data', $results, $BetterLinks->get_extra_rows(), $BetterLinks->get_link_id_map() ); -
/** * Lets an extension claim CSV rows the core importer does not recognise * (BetterLinks Pro: link rotations). Return a bucket name, or '' to skip. */ apply_filters( 'betterlinks/tools/import_row_bucket', '', $this->link_header ); -
/** * Filter the WPInsights optional_data payload before it is sent. */ apply_filters( 'betterlinks/wpinsights/optional_data', $body['optional_data'] ); -
apply_filters( 'betterlinks/is_extra_data_tracking_compatible', false ); -
apply_filters( 'betterlinks/admin/current_user_can_edit_settings', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/pre_before_redirect', $data ); -
apply_filters( 'betterlinks/api/analytics_items_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/link/get_link_by_slug', Helper::get_link_from_json_file( $slug ) ); -
betterlinks/site_url
filterapply_filters( 'betterlinks/site_url', site_url() ); -
do_action( 'betterlinks/admin/after_import_data' ); -
apply_filters( 'betterlinks/api/links_create_item_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/links_get_items_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/links_update_item_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/settings_get_items_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/links_update_favorite_permissions_check', current_user_can( 'manage_options' ) ); -
betterlinks/api/params
filterapply_filters( 'betterlinks/api/params', $params ); -
apply_filters( 'betterlinks/api/settings_update_items_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/terms_get_items_permissions_check', current_user_can( 'manage_options' ) ); -
betterlinks/before_redirect
actiondo_action( 'betterlinks/before_redirect', $data ); -
apply_filters( 'betterlinks/extra_tracking_data', $data, $dd ); -
do_action( 'betterlinks/link/after_insert_click', $item['link_id'], $click_id, $item['target_url'] ); -
apply_filters( 'betterlinks/link/before_dispatch_redirect', $data ); -
betterlinks/link/target_url
filterapply_filters( 'betterlinks/link/target_url', ( is_ssl() ? 'https:' : 'http:' ) . $url ); -
do_action( 'betterlinkspro/admin/check_password_protection', $data['short_url'], $data ); -
apply_filters( 'betterlinkspro/admin/current_user_can_edit_settings', current_user_can( 'manage_options' ) ); -
do_action( 'betterlinkspro/admin/update_link', $id, $arg ); -
apply_filters( 'betterlinkspro/admin/update_settings', $response ); -
apply_filters( 'betterlinkspro/get_individual_graph_data', $graph_data, $id, $from, $to ); -
apply_filters( 'betterlinks__intlfbs_filter_category_from_dashboard', '', $settings ); -
apply_filters( 'betterlinks_abilities_api_enabled', true ); -
betterlinks_ability_enabled
filterapply_filters( 'betterlinks_ability_enabled', self::abilities_enabled(), $this->id, $this ); -
betterlinks_admin_notices
actiondo_action( 'betterlinks_admin_notices' ); -
do_action( 'betterlinks_after_ability_execute', $this->id, $input, $output ); -
do_action( 'betterlinks_before_ability_execute', $this->id, $input ); -
betterlinks_before_cle
filterapply_filters( 'betterlinks_before_cle', $initial_values, $settings ); -
apply_filters( 'betterlinks_can_fetch_target_url', false ); -
do_action( 'betterlinks_compatibility_notices' ); -
betterlinks_loaded
actiondo_action( 'betterlinks_loaded' ); -
do_action( 'betterlinks_prevent_unwanted_cle' ); -
do_action( 'betterlinks_quick_link_creation' ); -
apply_filters( 'betterlinks_register_abilities', $abilities ); -
do_action( 'betterlinks_register_clicks_routes', $this ); -
do_action( 'betterlinks_update_notice_styles' ); -
apply_filters( 'BetterLinks/Admin/skip_no_conflict', false ); -
do_action( 'betterlinks/after_insert_link', $wpdb->insert_id, $item ); -
do_action( 'betterlinks/after_update_link', $item['ID'], $item ); -
apply_filters( 'betterlinks/analytics/where_clause', array( 'sql' => '', 'params' => array() ), $context ); -
apply_filters( 'betterlinks/api/analytics_delete_permissions_check', current_user_can( 'manage_options' ) ); -
apply_filters( 'betterlinks/api/terms_manage_permissions_check', current_user_can('manage_options') ); -
apply_filters( 'betterlinks/cle/allow_legacy_api_key', $allowed ); -
apply_filters( 'betterlinks/cle/legacy_api_key_grace_period', 90 * DAY_IN_SECONDS ); -
betterlinks/cle/rate_limit
filterapply_filters( 'betterlinks/cle/rate_limit', 20 ); -
apply_filters( 'betterlinks/cle/user_can_create', $can, wp_get_current_user() ); -
betterlinks/clicks_schema
filterapply_filters( 'betterlinks/clicks_schema', [ 'ID' => [ 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'link_id' => [ 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'ip' => [ 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'browser' => [ 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'os' => [ 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'referer' => [... ); -
do_action( 'betterlinks/elementor/controllers/before-end', $controls ); -
apply_filters( 'betterlinks/elementor/editor/after_save_data', $instant_redirect_data, $document ); -
apply_filters( 'betterlinks/fbs/current_user_can_manage_link', $can, absint( $task_id ) ); -
apply_filters( 'betterlinks/geolocation/cloudflare_ranges', array( '173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/13', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22', '2400:cb00::/32', '2606:4700::/32', '2803:f800::/32', '2405:b500::/32', '2405:8100::/32', '2a06:98c0::/29', '2c0f:... ); -
apply_filters( 'betterlinks/geolocation/forwarded_header', $default_header ); -
apply_filters( 'betterlinks/geolocation/trusted_proxies', $configured ); -
apply_filters( 'betterlinks/insert_link_default_args', $initial_defaults_arr ); -
do_action( 'betterlinks/link/before_start_tracking', $data ); -
betterlinks/links_schema
filterapply_filters( 'betterlinks/links_schema', [ 'ID' => [ 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'link_author' => [ 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'link_date' => [ 'type' => 'string', 'format' => 'date-time', ], 'link_date_gmt' => [ 'type' => 'string', 'format' => 'date-time', ], 'link_title' => [ 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'link_slug' => [ 'type' => 'str... ); -
do_action( 'betterlinks/make_cloaked_redirect', $target_url, $data ); -
betterlinks/pro_enabled
filterapply_filters( 'betterlinks/pro_enabled', defined( 'BETTERLINKS_PRO_VERSION' ) ); -
apply_filters( 'betterlinks/tools/export_content', array(), $type ); -
apply_filters( 'betterlinks/tools/migration/ptl_csv_import_link_arg', [ 'link_author' => $author_id, 'link_date' => isset($item['created_at']) ? $item['created_at'] : '', 'link_date_gmt' => isset($item['created_at']) ? $item['created_at'] : '', 'link_title' => isset($item['name']) ? $item['name'] : '', 'link_slug' => $slug, 'link_note' => '', 'link_status' => 'publish', 'nofollow' => isset($item['nofollow']) && $item['nofollow'] == 1 ? $item['nofollow'] : '', 'sp... ); -
apply_filters( 'betterlinks/tools/migration/ptl_one_click_import_link_arg', array( 'link_author' => $author_id, 'link_date' => $item['created_at'], 'link_date_gmt' => $item['created_at'], 'link_title' => $item['name'], 'link_slug' => $slug, 'link_note' => '', 'link_status' => 'publish', 'nofollow' => isset( $item['nofollow'] ) && $item['nofollow'] == 1 ? $item['nofollow'] : '', 'sponsored' => isset( $item['sponsored'] ) && $item['sponsored'] == 1 ? $item['sponsored'] :... ); -
apply_filters( 'betterlinks/tools/migration/s301_one_click_migration_args', [ 'link_author' => $author_id, 'link_date' => $now, 'link_date_gmt' => $now_gmt, 'link_title' => 'Simple 301 Redirects - ' . ltrim($request, '/'), 'link_slug' => \BetterLinks\Helper::make_slug('Simple 301 Redirects - ' . $destination), 'link_note' => '', 'link_status' => 'publish', 'nofollow' => $betterlinks_links->nofollow, 'sponsored' => $betterlinks_links->sponsored, 'track_me' => $betterlin... ); -
apply_filters( 'betterlinkspro/admin/parameter_tracking_values', array(), $data ); -
apply_filters( 'betterlinkspro/admin/split_test_tracking', false, $data ); -
btl_admin_notices
actiondo_action_deprecated( 'btl_admin_notices', array(), '3.1.4', 'betterlinks_admin_notices' ); -
btl_compatibity_notices
actiondo_action_deprecated( 'btl_compatibity_notices', array(), '3.1.4', 'betterlinks_compatibility_notices' ); -
apply_filters( "wpins_form_text_{$this->plugin_name}", $form );
Generated from BetterLinks's GPL-licensed source code. Hooks inside bundled third-party libraries are not listed.
Can't find the right hook?
We can build the customisation for you. Describe what you need: