Hooks & Filters Reference

Hooks & Filters Reference

Complete reference of action hooks and filters available in BuddyX Pro theme.

Action Hooks

Page Structure Hooks

buddyxbeforecontent

Fires before the main content wrapper.

Location: Before

Priority: Default (10)

add_action( 'buddyx_before_content', 'my_custom_content' );
function my_custom_content() {
    echo '<div class="my-custom-notice">Custom content here</div>';
}

buddyxaftercontent

Fires after the main content wrapper.

Location: After closing

(site-wrapper and container)

Priority: Default (10)

add_action( 'buddyx_after_content', 'my_custom_footer' );
function my_custom_footer() {
    echo '<div class="custom-cta">Call to action</div>';
}

buddyxsubheader

Fires in the sub-header area (page title section).

Location: After site header, before main content

Default Callback: buddyxsubheader() renders page header template

// Remove default page header
remove_action( 'buddyx_sub_header', 'buddyx_sub_header' );

// Add custom page header
add_action( 'buddyx_sub_header', 'my_custom_page_header' );
function my_custom_page_header() {
    echo '<div class="custom-page-header">Custom Header</div>';
}

Header Hooks

buddyx_header

Fires in the site header.

Location: Inside

element

Used For: Menu icons, search, cart

add_action( 'buddyx_header', 'my_custom_header_element', 15 );
function my_custom_header_element() {
    echo '<div class="custom-header-widget">My Widget</div>';
}

Footer Hooks

buddyxfooterbefore

Fires before the footer content.

Location: Before

opening tag

add_action( 'buddyx_footer_before', 'my_prefooter_content' );
function my_prefooter_content() {
    echo '<div class="pre-footer">Newsletter signup</div>';
}

buddyxfooterafter

Fires after the footer content.

Location: After

closing tag

add_action( 'buddyx_footer_after', 'my_postfooter_content' );
function my_postfooter_content() {
    echo '<div class="back-to-top"><a href="#top">Top</a></div>';
}

buddyxpagebottom

Fires at the bottom of the page before wp_footer().

Location: Inside before wp_footer()

add_action( 'buddyx_page_bottom', 'my_page_scripts' );
function my_page_scripts() {
    echo '<script>console.log("Page loaded");</script>';
}

buddyxbodybottom

Fires at the very end of the body.

Location: Right before closing tag

add_action( 'buddyx_body_bottom', 'my_analytics_code' );
function my_analytics_code() {
    echo '<script>/* Analytics code */</script>';
}

Sidebar Hooks

buddyxsidebarbefore

Fires before the sidebar widget area.

Location: Before

(sidebar closing)

add_action( 'buddyx_sidebar_after', 'my_sidebar_footer' );
function my_sidebar_footer() {
    echo '<div class="sidebar-ad">Advertisement</div>';
}

Comment Hooks

buddyxprobeforecommentreplay

Fires before the comment reply link.

Parameters:

  • $comment_id (int) – Comment ID
  • $comment (WP_Comment) – Comment object
add_action( 'buddyx_pro_before_comment_replay', 'my_comment_meta', 10, 2 );
function my_comment_meta( $comment_id, $comment ) {
    echo '<span class="comment-rating">Rating: 5 stars</span>';
}

buddyxproaftercommentreplay

Fires after the comment reply link.

Parameters:

  • $comment_id (int) – Comment ID
  • $comment (WP_Comment) – Comment object
add_action( 'buddyx_pro_after_comment_replay', 'my_comment_actions', 10, 2 );
function my_comment_actions( $comment_id, $comment ) {
    echo '<button class="report-comment">Report</button>';
}

buddyxpropostcommentbefore

Fires before the post comments section.

Location: Before comments template

add_action( 'buddyx_pro_post_comment_before', 'my_comment_notice' );
function my_comment_notice() {
    echo '<div class="comment-guidelines">Please be respectful</div>';
}

FluentCart Hooks

Product Page Hooks

All FluentCart product page hooks use priority 10 by default.

buddyxfluentcartbeforeproductcontent

Fires before all product content.

Location: Start of single product template

add_action( 'buddyx_fluentcart_before_product_content', 'my_product_notice' );
function my_product_notice() {
    echo '<div class="sale-banner">Limited Time Sale!</div>';
}

buddyxfluentcartbeforeproductheader

Fires before product title and meta.

add_action( 'buddyx_fluentcart_before_product_header', 'my_breadcrumbs' );
function my_breadcrumbs() {
    // Custom breadcrumb navigation
}

buddyxfluentcartafterproductheader

Fires after product title and meta.

Common Use: Trust badges, delivery info

add_action( 'buddyx_fluentcart_after_product_header', 'my_trust_badges' );
function my_trust_badges() {
    echo '<div class="trust-badges">';
    echo '<img src="secure-checkout.webp" alt="Secure Checkout">';
    echo '</div>';
}

buddyxfluentcartbeforeproductdescription

Fires before product description.

add_action( 'buddyx_fluentcart_before_product_description', 'my_key_features' );
function my_key_features() {
    global $product;
    // Display key features
}

buddyxfluentcartafterproductdescription

Fires after product description.

Common Use: Specifications, size charts

add_action( 'buddyx_fluentcart_after_product_description', 'my_specs_table' );
function my_specs_table() {
    echo '<div class="product-specs">';
    // Display specifications
    echo '</div>';
}

buddyxfluentcartproduct_tabs

Fires in the product tabs area.

Common Use: Reviews, FAQs, additional info

add_action( 'buddyx_fluentcart_product_tabs', 'my_custom_tabs' );
function my_custom_tabs() {
    echo '<div class="custom-tabs">';
    echo '<div class="tab">Reviews</div>';
    echo '<div class="tab">FAQs</div>';
    echo '</div>';
}

buddyxfluentcartbeforerelatedproducts

Fires before related products section.

add_action( 'buddyx_fluentcart_before_related_products', 'my_upsell_banner' );
function my_upsell_banner() {
    echo '<div class="upsell-notice">You may also like...</div>';
}

buddyxfluentcartafterrelatedproducts

Fires after related products section.

add_action( 'buddyx_fluentcart_after_related_products', 'my_recent_viewed' );
function my_recent_viewed() {
    // Display recently viewed products
}

buddyxfluentcartafterproductcontent

Fires after all product content.

Location: End of single product template

add_action( 'buddyx_fluentcart_after_product_content', 'my_product_footer' );
function my_product_footer() {
    echo '<div class="product-disclaimer">Terms apply</div>';
}

Filter Hooks

Search Filters

buddyxsearchslidetoggledata_attrs

Filters data attributes for search toggle button.

Returns: String of HTML attributes

add_filter( 'buddyx_search_slide_toggle_data_attrs', 'my_search_attrs' );
function my_search_attrs( $attrs ) {
    return 'data-animation="slide" data-speed="300"';
}

buddyxsearchfieldtoggledata_attrs

Filters data attributes for search field container.

Returns: String of HTML attributes

add_filter( 'buddyx_search_field_toggle_data_attrs', 'my_search_field_attrs' );
function my_search_field_attrs( $attrs ) {
    return 'data-position="right" data-overlay="true"';
}

BuddyPress Filters

bpnouveauthemecompatpagetemplatesdirectory_only

Filters whether the page is a BuddyPress directory.

Parameters:

  • $bpisdirectory (bool) – Whether page is directory

Returns: bool

add_filter( 'bp_nouveau_theme_compat_page_templates_directory_only', 'my_bp_directory_check' );
function my_bp_directory_check( $bp_is_directory ) {
    if ( is_page( 'my-custom-page' ) ) {
        return false;
    }
    return $bp_is_directory;
}

Authentication Filters

authenticate

Modified in BuddyX Pro to handle inactive signups.

Parameters:

  • $user (WPUser|WPError) – User object or error
  • $username (string) – Username
  • $password (string) – Password

Priority: 10

add_filter( 'authenticate', 'my_custom_auth', 20, 3 );
function my_custom_auth( $user, $username, $password ) {
    // Custom authentication logic
    return $user;
}

login_url

Filtered during inactive signup redirects.

Parameters:

  • $login_url (string) – Login URL

Returns: string – Modified login URL

add_filter( 'login_url', 'my_custom_login_url', 20 );
function my_custom_login_url( $login_url ) {
    return add_query_arg( 'custom_param', '1', $login_url );
}

Component Hooks

Components can add their own hooks via the initialize() method:

Creating Custom Component Hooks

namespace BuddyxPro\BuddyxPro\MyComponent;

use BuddyxPro\BuddyxPro\Component_Interface;

class Component implements Component_Interface {

    public function initialize() {
        // Add actions
        add_action( 'wp_head', array( $this, 'add_meta_tags' ) );
        add_action( 'wp_footer', array( $this, 'add_schema' ) );

        // Add filters
        add_filter( 'body_class', array( $this, 'add_body_classes' ) );
    }

    public function add_body_classes( $classes ) {
        $classes[] = 'my-custom-class';
        return $classes;
    }
}

WordPress Core Hooks Used

wpenqueuescripts

Used by Styles and Scripts components.

Priority: Default (10)

// Theme uses this for asset loading
add_action( 'wp_enqueue_scripts', 'buddyx_enqueue_styles' );
add_action( 'wp_enqueue_scripts', 'buddyx_enqueue_scripts' );

aftersetuptheme

Used for theme feature registration.

Priority: Default (10)

add_action( 'after_setup_theme', 'buddyx_theme_updater' );
add_action( 'after_setup_theme', 'buddyx_buddypress_nouveau_support' );

widgets_init

Used for sidebar and widget registration.

add_action( 'widgets_init', 'buddyx_register_sidebars' );
add_action( 'widgets_init', 'buddyx_register_widgets' );

admin_init

Used for admin-specific functionality.

add_action( 'admin_init', 'buddyx_fontawesome_dashboard' );
add_action( 'admin_init', 'buddyx_pro_theme_setting_update', 99 );

template_include

Used for AMP template routing.

Priority: 9999992233720368547758099 (very late)

add_filter( 'template_include', 'buddyx_theme_amp_templatre_include', '9999992233720368547758099' );

Hook Priority Reference

HookPriorityPurpose
buddyxbeforecontent10Content wrapper opening
buddyxaftercontent10Content wrapper closing
buddyxsubheader10Page header display
buddyx_header10-15Header elements
buddyxfluentcart*10FluentCart integrations
authenticate10BuddyX signin handling
login_url10Inactive signup redirects
template_include9999…AMP routing (very late)

Custom Hook Examples

Add Content After Product Title

add_action( 'buddyx_fluentcart_after_product_header', 'add_delivery_estimate' );
function add_delivery_estimate() {
    echo '<div class="delivery-info">';
    echo '<i class="fa fa-truck"></i> ';
    echo 'Delivers in 2-3 business days';
    echo '</div>';
}

Modify Body Classes

add_filter( 'body_class', 'add_custom_body_class' );
function add_custom_body_class( $classes ) {
    if ( is_user_logged_in() ) {
        $classes[] = 'user-logged-in';
    }
    return $classes;
}

Add Custom Sidebar Widget

add_action( 'buddyx_sidebar_before', 'add_featured_content' );
function add_featured_content() {
    if ( is_singular( 'post' ) ) {
        echo '<div class="featured-posts">';
        // Display featured posts
        echo '</div>';
    }
}

Remove Default Page Header

// Remove on specific pages
add_action( 'wp', 'conditionally_remove_page_header' );
function conditionally_remove_page_header() {
    if ( is_page( 'landing' ) ) {
        remove_action( 'buddyx_sub_header', 'buddyx_sub_header' );
    }
}

Best Practices

Do

  • Use appropriate hook priority (lower = earlier)
  • Check context before outputting content
  • Escape all output (eschtml, escattr)
  • Use conditional tags (issingular, ispage)
  • Prefix custom function names
  • Return filtered values (don’t modify directly)

Don’t

  • Use very high or low priorities unnecessarily
  • Remove core theme hooks without testing
  • Echo in filter callbacks (return instead)
  • Add heavy processing in early hooks
  • Forget to check if hooks exist

Debugging Hooks

List All Hooks on a Page

// In functions.php
if ( WP_DEBUG ) {
    add_action( 'wp_footer', 'debug_hooks' );
    function debug_hooks() {
        global $wp_filter;
        echo '<pre>';
        print_r( array_keys( $wp_filter ) );
        echo '</pre>';
    }
}

Check Hook Priority

// Check what's hooked to buddyx_header
global $wp_filter;
if ( isset( $wp_filter['buddyx_header'] ) ) {
    print_r( $wp_filter['buddyx_header']->callbacks );
}

Related Documentation

Last updated: January 31, 2026