[buddypress-trac] [BuddyPress] #4855: Method to override a plugins use of plugins.php or add filters to bp_template_title and bp_template_content
buddypress-trac
noreply at wordpress.org
Tue Mar 5 06:21:48 UTC 2013
#4855: Method to override a plugins use of plugins.php or add filters to
bp_template_title and bp_template_content
-------------------------------+-----------------------------
Reporter: modemlooper | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future Release
Component: Core | Version:
Severity: normal | Resolution:
Keywords: reporter-feedback |
-------------------------------+-----------------------------
Changes (by r-a-y):
* keywords: 2nd-opinion reporter-feedback => reporter-feedback
Comment:
The `'bp_template_content'` hook should be satisfactory, modemlooper.
The problem is you are trying to unhook the function too early.
----
Let's follow the yellow brick road!
1. You're trying to remove this function call -
`bbp_member_forums_topics_content()`
2. `bbp_member_forum_topics_content()` is called from
`bbp_member_forums_screen_topics()`:
https://bbpress.trac.wordpress.org/browser/tags/2.2.4/includes/extend/buddypress/functions.php#L86
3. `bbp_member_forums_screen_topics()` is called from
`BBP_Forums_Component::setup_nav()`:
https://bbpress.trac.wordpress.org/browser/tags/2.2.4/includes/extend/buddypress/loader.php#L189
4. The `setup_nav()` method runs `bp_core_new_subnav_item()`:
https://buddypress.trac.wordpress.org/browser/tags/1.7-beta1/bp-core/bp-
core-buddybar.php#L199
5. `bp_core_new_subnav_item()` is used to pass the screen function -
`bbp_member_forums_topic_content()` from point no. 1:
https://buddypress.trac.wordpress.org/browser/tags/1.7-beta1/bp-core/bp-
core-buddybar.php#L279
Now, we've reached the end of the road!
----
The hook you're looking at is "bp_screens" and "bp_screens" runs at
"bp_template_redirect" at priority 6.
https://buddypress.trac.wordpress.org/browser/tags/1.7-beta1/bp-core/bp-
core-actions.php#L74
'''Conclusion:''' Run your hook any time after "bp_template_redirect" at
priority 6.
Like so:
{{{
function bp4855() {
remove_action( 'bp_template_content',
'bbp_member_forums_topics_content' );
}
add_action( 'bp_template_redirect', 'bp4855' );
}}}
This runs your removal hook at "bp_template_redirect" at priority 10,
which is after when BuddyPress / bbPress runs its hook.
I wrote this quite quick, so I might be skipping a few steps, but
hopefully you understand what you need to do in the future.
Run your code after the hook you want to override has executed.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4855#comment:11>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list