Search code examples
wordpressbuddypress

How the actions work in BuddyPress?


I am working with BuddyPress; and, there are many actions, such as: do_action('bp_before_wrapper'), do_action( 'bp_before_bodywrap' ), do_action( 'bp_before_container' )...; bu, I didn't find where define such actions.

Are they default actions in BuddyPress?


Solution

  • do_action is a WordPress call. There may be actions hooked to a do_action or it may just be there so developers can call it if they want.

    For example do_action( 'bp_before_container' ); is not hooked to anything, but you could write a function that hooks to it.

    function snail_content() {
        echo 'I am a snail';
    }
    add_action('bp_before_container', 'snail_content' );
    

    Read the WP codex re do_action.

    btw - do_action( 'bp_before_container' ); is in bp-themes which is deprecated. Use the files in bp-templates.