How to hide the Product Menu for non-admin users?


  • In Liferay DXP 7.0 and 7.1, there may be the requirement to hide the Product Menu (along with the icon to open it) to certain roles (for example, regular/non-admin, site users):



  • Liferay 7.0 DXP
  • Liferay 7.1 DXP


  • Liferay DXP does not provide a way to achieve the requirement out of the box.
  • It is possible to achieve the desired behavior with customization. There are two main ways of approaching this requirement, both connected.

1. Custom theme

In the portal_normal.ftl of a custom theme, surround the <@liferay.control_menu /> tag with a permission check, something like:

<#if is_signed_in>
    <#assign roles = user.getRoles() 
           showcontrolmenu = false
    <#list roles as role>
         <#if role.getName() == "Administrator" || role.getName() == "Other Role" >
                   <#assign showcontrolmenu = true />
    <#if showcontrolmenu>
        <@liferay.control_menu />

As an alternative to this, the necessary code may also be constructed in the theme's init.ftl:

permission_checker = themeDisplay.getPermissionChecker() 
is_group_admin = permission_checker.isGroupAdmin(group_id)
is_omniadmin = permission_checker.isOmniadmin()
show_dockbar = is_group_admin || is_omniadmin

and then used:

<#if show_dockbar> 
<@liferay_ui["quick-access"] contentId="#main-content" />
<@liferay_util["include"] page=body_top_include />
<@liferay.control_menu />

in the portal_normal.ftl. In addition to this, the Product Menu margin might require adjustment after the change. In main.css, something like:

@media only screen and (min-width:768px){ #wrapper{

could help to resolve the visual gap.

2. Control Menu Entry / Theme Contributors / Template Context Contributor

For this approach, here is a list of the related tutorials:

Added to the above, also some community resources:

Please note: In both cases, (at least) the option to Sign Out (/c/portal/logout):


shall be moved elsewhere through your portal's theme, else, with the Product Menu disabled, it will be unreachable.

Additional Information

  • The Product Menu has been dis-joined from regular user roles in the latest release, therefore this will no longer be an issue as of Liferay DXP 7.2+
  • The resources provided are purely a hint to help the custom development, the implementation will be up to each developer's discretion.
2 人中有 2 人觉得有帮助