replace a function added in external class

I’m using wp 3.9, bp 2.0.1 and the bp-groupblog plugin 1.8.5. In the ‘create_screen’-function in BP_Groupblog_Extension-class (extending the BP_Group_Extension-class) the plugin adds an action:

function create_screen( $group_id = null ) {
    add_action( 'bp_groupblog_create_screen_markup', 'bp_groupblog_signup_blog' );
    do_action( 'bp_groupblog_create_screen_markup' );

To customize the group-blog-registration-HTML I need to replaced ‘bp_groupblog_signup_blog’-function.

Code in pb-custom.php:

function replace_bp_groupblog_signup_blog() {
   remove_action('bp_groupblog_create_screen_markup', 'bp_groupblog_signup_blog');
    function my_bp_groupblog_signup_blog($blogname = '', $blog_title = '', $errors = ''){      
        // all the code
    add_action( 'bp_groupblog_create_screen_markup', 'my_bp_groupblog_signup_blog');

add_action( 'plugins_loaded', 'replace_bp_groupblog_signup_blog' );

I can add a customized function bud i can’t remove the original one and I’m getting the HTML for both functions displayed on my page now .
The ‘has_action’ returns false at the time of the remove_action. So I’m hooking too early? I checked the action-hooklist (, tried ‘bp_include’, ‘bp_loaded’, added/altered the priority etc bud nothing works.

How is it done?


Read more here: replace a function added in external class

Leave a Reply

Your email address will not be published. Required fields are marked *