Is there any way to hide the pages from the site according to the user group?

I have tried the below code.

isusermemberofgroup( username:loggedInUser(), groupId:cons!UMS_ASSIGNEE_GROUP )

But it is not working. Is there any other way to hide the pages from the site according to the user group?

  Discussion posts and replies are publicly visible