/* * Function determines if WordPress user (current or by ID) is a WooCommerce shop manager. * * @return bool */ function is_shop_manager( $user_id = 0 ) { $the_user = ( 0 == $user_id ) ? wp_get_current_user() : get_user_by( 'id', $user_id ); return ( isset( $the_user->roles[0] ) && 'shop_manager' === $the_user->roles[0] ) ? true : false; }