#4751 closed defect (bug) (no action required)
remove action bp_member_header_actions priority wonky
Reported by: | modemlooper | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.7 |
Component: | Templates | Keywords: | reporter-feedback close |
Cc: |
Description
in functions php we have this:
add_action( 'bp_member_header_actions', 'bp_send_public_message_button', 20 );
to remove:
remove_action( 'bp_member_header_actions', 'bp_send_public_message_button', 20 );
This works great but the add friends button is set at priority 5 and if you use this:
remove_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 );
It doesn't remove the action.
only if the integer is above 10 will it remove the action.
if I change the add action in functions to:
add_action( 'bp_member_header_actions', 'bp_add_friend_button', 11 );
I can then remove it with:
remove_action( 'bp_member_header_actions', 'bp_add_friend_button', 11 );
not sure whats blocking priority 1-10
Change History (7)
#2
@
12 years ago
- Keywords reporter-feedback added; dev-feedback removed
Have the buttons changed priority or hook in 1.7, or does this issue likely exist in 1.6, too?
#4
@
12 years ago
- Keywords close added
- Milestone Awaiting Review deleted
It's an action firing thing.
All the member header actions are added during the 'after_setup_theme'
hook, which runs after 'plugins_loaded'
or 'bp_include'
:
https://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-actions.php#L88 (theme compat)
https://buddypress.trac.wordpress.org/browser/trunk/bp-themes/bp-default/functions.php#L141 (bp-default)
Therefore, in this case, you need to run your code after the 'after_setup_theme'
hook.
If we use your example remove_add_friend()
function, you can do the following at the earliest juncture:
function remove_add_friend() { remove_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 ); } add_action( 'after_setup_theme', 'remove_add_friend', 11 );
I'm guessing you were running your code at an earlier hook like 'bp_include'
, which is why your remove_action() was not working as intended.
more info
I figured that if I wrap remove action in a function I can get it to remove by using a 0 priority in the function. The other buttons do not require this.