BP_Core_Members_Switching::action_admin_bar_menu( WP_Admin_Bar $wp_admin_bar )

Adds a ‘Switch back to {user}’ link in WordPress’ admin bar.

Description

Parameters

$wp_admin_bar

(WP_Admin_Bar) (Required) The admin bar object.

Source

File: bp-members/classes/class-bp-core-members-switching.php

	public function action_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {
		if ( ! function_exists( 'is_admin_bar_showing' ) ) {
			return;
		}
		if ( ! is_admin_bar_showing() ) {
			return;
		}

		$old_user = self::get_old_user();

		if ( $old_user ) {
			$wp_admin_bar->add_menu( array(
				'parent' => 'top-secondary',
				'id'     => 'switch-back',
				'title'  => esc_html( sprintf(
					__( 'Switch back to Admin', 'buddyboss' ),
					$old_user->display_name,
					$old_user->user_login
				) ),
				'href'   => add_query_arg( array(
					'redirect_to' => urlencode( self::current_url() ),
				), self::switch_back_url( $old_user ) ),
			) );
		}

	}

Changelog

Changelog
Version Description
BuddyBoss 1.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.