You need to wrap this code in portal_normal.ftl
in your theme.
<@liferay.control_menu />
You can create a theme context contributor to add a value into the model that will determine if the user should or should not get the menu.
the code could be something like this
Boolean isAdmin = false;
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
try {
Group group = themeDisplay.getScopeGroup();
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (themeDisplay.isSignedIn() && groupPermission.contains(permissionChecker, group,
ActionKeys.VIEW_SITE_ADMINISTRATION)) {
isAdmin = true;
}
} catch (PortalException e) {
LOG.warn(e);
}
contextObjects.put("is_site_admin", isAdmin);
The key is to use the permission checker.