BP_Members_Admin::profile_admin_head()

Highlight the Users menu if on Edit Profile and check if on the user’s admin profile.

Description

Source

File: bp-members/classes/class-bp-members-admin.php

	public function profile_admin_head() {
		global $submenu_file, $parent_file;

		// Is the user editing their own profile?
		if ( is_user_admin() || ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) ) {
			$this->is_self_profile = true;

		// Is the user attempting to edit their own profile.
		} elseif ( isset( $_GET['user_id' ] ) || ( isset( $_GET['page'] ) && ( 'bp-profile-edit' === $_GET['page'] ) ) ) {
			$this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id );
		}

		// Force the parent file to users.php to open the correct top level menu
		// but only if not editing a site via the network site editing page.
		if ( 'sites.php' !== $parent_file ) {
			$parent_file  = 'users.php';
			$submenu_file = 'users.php';
		}

		// Editing your own profile, so recheck some vars.
		if ( true === $this->is_self_profile ) {

			// Use profile.php as the edit page.
			$edit_page = 'profile.php';

			// Set profile.php as the parent & sub files to correct the menu nav.
			if ( is_blog_admin() || is_user_admin() ) {
				$parent_file  = 'profile.php';
				$submenu_file = 'profile.php';
			}

		// Not editing yourself, so use user-edit.php.
		} else {
			$edit_page = 'user-edit.php';
		}

		if ( is_user_admin() ) {
			$this->edit_profile_url = add_query_arg( $this->edit_profile_args, user_admin_url( 'profile.php' ) );
			$this->edit_url         = user_admin_url( 'profile.php' );

		} elseif ( is_blog_admin() ) {
			$this->edit_profile_url = add_query_arg( $this->edit_profile_args, admin_url( 'users.php' ) );
			$this->edit_url         = admin_url( $edit_page );

		} elseif ( is_network_admin() ) {
			$this->edit_profile_url = add_query_arg( $this->edit_profile_args, network_admin_url( 'users.php' ) );
			$this->edit_url         = network_admin_url( $edit_page );
		}
	}

Changelog

Changelog
Version Description
BuddyPress 2.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.