Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#4751 closed defect (bug) (no action required)

remove action bp_member_header_actions priority wonky

Reported by: modemlooper's profile 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)

#1 @modemlooper
12 years ago

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.

function remove_add_friend() {

	 remove_action( 'bp_member_header_actions',    'bp_add_friend_button', 5 );
}
add_action( 'bp_member_header_actions', 'remove_add_friend', 0 );

#2 @DJPaul
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?

#3 @modemlooper
12 years ago

1.6 & 1.7

easiest fix is bump friend button to priority above 10

#4 @r-a-y
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.

#5 @modemlooper
12 years ago

Thanks ray!

#6 @modemlooper
12 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#7 @DJPaul
8 years ago

  • Component changed from Appearance - Template Parts to Templates
Note: See TracTickets for help on using tickets.