wc_disable_admin_bar( bool $show_admin_bar )

Prevent any user who cannot ‘edit_posts’ (subscribers, customers etc) from seeing the admin bar.


Description Description

Note: get_option( ‘woocommerce_lock_down_admin’, true ) is a deprecated option here for backwards compatibility. Defaults to true.


Parameters Parameters

$show_admin_bar

(Required) If should display admin bar.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/wc-user-functions.php

function wc_disable_admin_bar( $show_admin_bar ) {
	if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) {
		$show_admin_bar = false;
	}

	return $show_admin_bar;
}


Top ↑

User Contributed Notes User Contributed Notes

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