Home Forums WoodMart support forum User permissions for METABOXES of pages and posts Reply To: User permissions for METABOXES of pages and posts

#514020

Hung Pham
Keymaster

Hi staffcreator,

Please add below Custom Code to functions.php file in Child theme.

The metaboxes are not displayed unless the user is logged in as an admin

add_action( 'init', function () {
	$user = wp_get_current_user();

	if ( empty( $user->roles ) || ! in_array( 'administrator', $user->roles, true ) ) {
		remove_action( 'init', 'woodmart_register_page_metaboxes', 100 );
		remove_action( 'init', 'woodmart_register_product_metaboxes', 100 );
	}
});

Regards,