• Resolved Rocio Valdivia

    (@_dorsvenabili)


    Hi Boone, great job with the plugin, thanks πŸ™‚

    I’m trying to remove the following hook because I need to allow the access to some users depending some usermeta value. But I can’t get to remove the action:

    remove_action( 'template_redirect', array( $this, 'protect_doc_access' ) );

    The var $this should have the same values than when it was defined with add_action, but if I try to define $this I get a white screen.

    Using remove_all_actions I get it, but I can’t use it because I have other redirections that can not be removed.

    Any ideas how to get it?

    Thanks in advance πŸ™‚

    https://wordpress.org/plugins/buddypress-docs/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Boone Gorges

    (@boonebgorges)

    Hi Rocio – The object referred to by $this is in the $bp_docs global. So you should be able to do this:

    remove_action( 'template_redirect', array( $GLOBALS['bp_docs'], 'protect_doc_access' ) );

    You’ll need to do this *after* the hook has been added. So another, more reliable technique might be:

    function bbg_unhook_doc_access() {
            global $bp_docs;
            remove_action( 'template_redirect', array( $bp_docs, 'protect_doc_access' ) );
    }
    add_action( 'bp_init', 'bbg_unhook_doc_access' );

    By bp_init, you can be sure that the action has been added, so it’ll be there to remove.

    Let me know if this helps.

    Thread Starter Rocio Valdivia

    (@_dorsvenabili)

    It works perfectly, thanks a lot Boone! πŸ˜€

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to remove the single's doc redirection’ is closed to new replies.