BP_Members_Admin::profile_nav( object|null $user = null, string $active = 'WordPress' )

Create the Profile navigation in Edit User & Edit Profile pages.

Description

Parameters

$user

(Optional) User to create profile navigation for.

Default value: null

$active

(Optional) Which profile to highlight.

Default value: 'WordPress'

Return

(string|null)

Source

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

	public function profile_nav( $user = null, $active = 'WordPress' ) {

		// Bail if no user ID exists here.
		if ( empty( $user->ID ) ) {
			return;
		}

		// Add the user ID to query arguments when not editing yourself.
		if ( false === $this->is_self_profile ) {
			$query_args = array( 'user_id' => $user->ID );
		} else {
			$query_args = array();
		}

		// Conditionally add a referer if it exists in the existing request.
		if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
			$wp_http_referer = wp_unslash( $_REQUEST['wp_http_referer'] );
			$wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
			$query_args['wp_http_referer'] = urlencode( $wp_http_referer );
		}

		// Setup the two distinct "edit" URL's.
		$community_url = add_query_arg( $query_args, $this->edit_profile_url );
		$wordpress_url = add_query_arg( $query_args, $this->edit_url         );

		$bp_active = false;
		$wp_active = ' nav-tab-active';
		if ( 'BuddyPress' === $active ) {
			$bp_active = ' nav-tab-active';
			$wp_active = false;
		} ?>

		<h2 id="profile-nav" class="nav-tab-wrapper">
			<?php
			/**
			 * In configs where BuddyPress is not network activated, as regular
			 * admins do not have the capacity to edit other users, we must add
			 * this check.
			 */
			if ( current_user_can( 'edit_user', $user->ID ) ) : ?>

				<a class="nav-tab<?php echo esc_attr( $wp_active ); ?>" href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddyboss' ); ?></a>

			<?php endif; ?>

			<a class="nav-tab<?php echo esc_attr( $bp_active ); ?>" href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddyboss' ); ?></a>
		</h2>

		<?php
	}

Changelog

Changelog
Version Description
BuddyPress 2.0.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.