Digital Sovereignty for everyone

Member header actions

The buttons in a member’s profile header are gathered from the bp_localhero_member_actions filter instead of being echoed one after another onto bp_member_header_actions, so they can be ordered and grouped. There are two tiers only:

  • Primary: one or two key actions, shown as buttons. By default these are Add Friend (or the current friendship state) and Private Message.
  • More: everything else, admin actions included, in a single More menu. There is no separate staff menu. Public Message (@mention) is here by default.

The More menu is a details element, so it opens without JavaScript. When open, it takes its own row under the primary buttons, with its actions outlined in a box and styled like the other header buttons, and its toggle reads Less. With JavaScript, it also closes on a click outside it or on Escape.

Adding an action

add_filter( 'bp_localhero_member_actions', function ( $actions, $user_id ) {
	if ( ! is_user_logged_in() || get_current_user_id() === $user_id ) {
		return $actions;
	}

	$actions['my-action'] = array(
		'label'      => __( 'Do something', 'my-plugin' ),
		'url'        => $url,      // link target, or form target when method is post
		'method'     => 'post',    // get (a link) or post (a form; url must carry _wpnonce)
		'group'      => 'more',    // primary or more
		'priority'   => 50,        // lower comes first within its group
		'capability' => 'edit_users', // or array( capability, ...args )
		'confirm'    => __( 'Are you sure?', 'my-plugin' ),
	);

	return $actions;
}, 10, 2 );

Instead of url and label, an action can give a render callable, called with the displayed member’s ID and the action, which returns or echoes its own markup (for example a form it builds itself). Decide whether an action applies at all (logged out, own profile, relationship state) before adding it; an action whose markup comes out empty is left out. A confirm text is shown by the pack’s script before the link or form is followed.

bp_localhero_member_actions_primary_limit sets how many primary actions are shown as buttons (default 2). Primary actions beyond the limit go to the top of the More menu.

Back-compat

bp_member_header_actions still fires, inside the More menu, so buttons from plugins that have not moved to the filter (User Switching, for example) still appear there. A theme or plugin that overrides members/single/member-header.php or cover-image-header.php should call bp_localhero_theme_member_header_actions() in place of do_action( 'bp_member_header_actions' ); otherwise the registry’s actions are not shown. LH plugins move to the filter one at a time; LH Buddypress Block Members was the first.

Member name

Both member headers show the member’s full name as their heading, in place of BP Legacy’s @mention name.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.