Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Replace plugin-function from bp-groupblog – double output


  • uvo
    Participant

    @uvo

    I’m using wp 3.9, bp 2.0.1 and the bp-groupblog plugin 1.8.5. To customize the group-blog-registration-HTML I replaced the bp_groupblog_signup_blog-function by creating this function in the bp-custom.php file:

    function replace_bp_groupblog_signup_blog() {
        remove_action('bp_groupblog_create_screen_markup', 'bp_groupblog_signup_blog');
        remove_action( 'bp_groupblog_edit_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( 'bp_groupblog_edit_screen_markup', 'my_bp_groupblog_signup_blog' );
    }
    
    add_action( 'plugins_loaded', 'replace_bp_groupblog_signup_blog' );
    

    Now the output of both function, the customized and the original one, is shown. Is the bp-custom.php the right place to remove and add functions?

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)

  • shanebp
    Moderator

    @shanebp

    You’ll probably get a better answer using the support forum for that plugin.

    My guess would be that you are hooking too early and the remove_action calls fire before those add_actions exist.
    Maybe try a hook other than ‘plugins_loaded’.
    Have you tried ‘bp_include’.


    uvo
    Participant

    @uvo

    You are right. “has_action” returns false at the time of the remove_action. Unfortunately bp_include did not help. I checked the action-hooklist (http://goo.gl/C5exli) bud i can’t figure out, which hook is the right one.
    If I replace the action in the bp-groupblog-classes.php (create_screnn() & edit_screen()) where the original function is hooked and excecutet (do_action) the output is correct. Bud I don’t want to edit the original class.
    Is there a way to overwrite the plugin class or is my first approach the better way and if yes, how can i find the correct hook?

    Thanks.


    uvo
    Participant

    @uvo

    I didn’t found a solution for this problem yet. I have maybe tried hundreds of variations but nothing works yet. Can anybody point me in the right direction?


    uvo
    Participant

    @uvo

    Changing the remove-action solved the problem:

    add_action(
      'bp_groupblog_create_screen_markup',
      function() {
          remove_action( current_filter(), 'bp_groupblog_signup_blog' );
      },
      9
    );

    Found the solution here.


    shanebp
    Moderator

    @shanebp

    Nice. And thanks for the link to the discussion.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Replace plugin-function from bp-groupblog – double output’ is closed to new replies.
Skip to toolbar