Search code examples
phpwordpresstemplateshookbuddypress

Where do I find the source of a 'hook' in order to alter its output?


Basic question. There's a hook I want to alter and I have no idea where to find it. Here's the code I'm working with. The hook in specific is 'bp_before_member_header_meta'

"

/**
 * BuddyPress - Users Header
 *
 * @package BuddyPress
 * @subpackage bp-default
 */

?>

<?php do_action( 'bp_before_member_header' ); ?>


<div id="item-header-content">
    <div class="auther-part">
        <div id="item-header-avatar">
            <a href="<?php bp_displayed_user_link(); ?>">
                <?php bp_displayed_user_avatar( 'type=full' ); ?>
            </a>
        </div><!-- #item-header-avatar -->

        <div class="auther-sidebar">
        <div id="item-meta">

            <div id="item-buttons">

            </div><!-- #item-buttons -->
            <?php do_action( 'bp_before_member_header_meta' ); ?>
            <?php do_action( 'bp_member_header_actions' ); ?>

Solution

  • There is a global array called $wp_filter that contains the invocations of actions and filters, so if you look in $wp_filter['bp_before_member_header'] you will get the current invocations of that action.

    You can also use your IDE or grep to look for occurrences of add_action in code. This doesn't always find them since the names are sometimes built by code. I spent half an hour today looking for an action in Shopp that was built that way.

    Edit: The other side of the action-filter world is found in plugin.php functions do_action and apply_filters. this is the code that actually runs actions and filters, so you can look for calls to this if you want to know where a filter is run. It takes the filter name as an argument and runs all the matching filters in the order specified. It looks like you already know where these are.