bp_members_admin_bar_user_admin_menu()

Add the User Admin top-level menu to user pages.


Description Description


Source Source

File: bp-members/bp-members-adminbar.php

function bp_members_admin_bar_user_admin_menu() {
	global $wp_admin_bar;

	// Only show if viewing a user.
	if ( !bp_is_user() )
		return false;

	// Don't show this menu to non site admins or if you're viewing your own profile.
	if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
		return false;

	$bp = buddypress();

	// Unique ID for the 'My Account' menu.
	$bp->user_admin_menu_id = 'user-admin';

	// Add the top-level User Admin button.
	$wp_admin_bar->add_menu( array(
		'id'    => $bp->user_admin_menu_id,
		'title' => __( 'Edit Member', 'buddypress' ),
		'href'  => bp_displayed_user_domain()
	) );

	if ( bp_is_active( 'xprofile' ) ) {
		// User Admin > Edit this user's profile.
		$wp_admin_bar->add_menu( array(
			'parent' => $bp->user_admin_menu_id,
			'id'     => $bp->user_admin_menu_id . '-edit-profile',
			'title'  => __( "Edit Profile", 'buddypress' ),
			'href'   => bp_get_members_component_link( 'profile', 'edit' )
		) );

		// User Admin > Edit this user's avatar.
		if ( buddypress()->avatar->show_avatars ) {
			$wp_admin_bar->add_menu( array(
				'parent' => $bp->user_admin_menu_id,
				'id'     => $bp->user_admin_menu_id . '-change-avatar',
				'title'  => __( "Edit Profile Photo", 'buddypress' ),
				'href'   => bp_get_members_component_link( 'profile', 'change-avatar' )
			) );
		}

		// User Admin > Edit this user's cover image.
		if ( bp_displayed_user_use_cover_image_header() ) {
			$wp_admin_bar->add_menu( array(
				'parent' => $bp->user_admin_menu_id,
				'id'     => $bp->user_admin_menu_id . '-change-cover-image',
				'title'  => __( 'Edit Cover Image', 'buddypress' ),
				'href'   => bp_get_members_component_link( 'profile', 'change-cover-image' )
			) );
		}

	}

	if ( bp_is_active( 'settings' ) ) {
		// User Admin > Spam/unspam.
		$wp_admin_bar->add_menu( array(
			'parent' => $bp->user_admin_menu_id,
			'id'     => $bp->user_admin_menu_id . '-user-capabilities',
			'title'  => __( 'User Capabilities', 'buddypress' ),
			'href'   => bp_displayed_user_domain() . 'settings/capabilities/'
		) );

		// User Admin > Delete Account.
		$wp_admin_bar->add_menu( array(
			'parent' => $bp->user_admin_menu_id,
			'id'     => $bp->user_admin_menu_id . '-delete-user',
			'title'  => __( 'Delete Account', 'buddypress' ),
			'href'   => bp_displayed_user_domain() . 'settings/delete-account/'
		) );

	}

}

Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.