Setting up reports to be visible on the live site to only certain users.
Recently we had a solution provider who was wondering if it was possible to set up multiple reports which appear on the white-facing live site but were also restricted so that only certain users would be able to see them. We were able to come up with a setup which did exactly this using the reports module, membership module and the web pages module. We will now walk you through the steps used to set this up.
The first thing you need is to set up the reports. Navigate to the reports module in Orange. Add a new report. Add info into the required fields at the top: give it a name (here I used 'members') and category, set the frequency to manual, the data source to SQL, and check the box which is next to the label "Allow this report to be accessed on the live website". You can leave the color as is, it does not matter which it is set to. Scroll down to the SQL statement section. Here you can insert any SQL statement you want, but in this example we will be showing a list of the users registered with the white-facing site. The relevant SQL statement is "SELECT `user`, `email` FROM `membership_users` LIMIT 10;".
In the Report Output section, switch it from DB Table to HTML Layout. In the Body section, put [[repeat]]. In the Repeat section, put [[item]]. In the item section, you will need to put the columns from your SQL result in the order you wish them to be displayed, separated by commas. So in this example, we would put "[[user]], [[email]]" in the Item section.
You have now finished setting up a report to be displayed on the white-facing site. Go back to the main tab of the reports module, add another new report, and set it up in the same way except this time name it 'blogs', use the SQL query "SELECT `title` FROM `blog` LIMIT 10;". In the 'Item' section, type [[title]]. Save.
You now have two reports which detail different things:
The next step we will be taking is to set up user restrictions. Navigate to the Membership module in Orange. You will need to set up both 'Categories' and 'Restrictions'. Each web page which you want to be locked to a specific set of users will need to be set up with a single 'Restriction'. Each member is always set up with a single category. The membership categories are then linked to one or more restrictions, meaning that each member will have access to some number of pages depending on which category they are assigned to.
Click on the Restrictions tab. Add a new one by giving it a name and clicking save. Now add another with a different name and save. Now go to the Category tab. Add a new one, give it a name and check only one of the boxes under the Restrictions header, then click save. Add another category with a new name, but this time check the other box under the Restrictions header. You now have two different membership categories which are linked to different restrictions.
The next step is to add multiple users. Navigate to the first tab of the Membership module in Orange, and add a user. Fill out the required fields - name, password, email, and give it one of the two categories you just made. Now make another user but this time set the user to the other category that you previously set up. At this point you have multiple users who are attached to different categories which have different restrictions, and therefore once the setup is complete, will be able to see different restricted sections of the site.
The only part of this setup which is left is to set up web pages which are attached to specific restriction levels and therefore cannot be seen except by people who are in a membership category which has access to that page. Go to the Blue web pages module and add a new page. Give it a category, link and title. At the bottom section called 'Membership Info', select the first restriction you set up earlier. In the content section, you will need to insert text to turn into a hyperlink - here we used 'View Report'. Highlight the text and click the 'insert link' button. Select 'Reports' from the first dropdown, then click next. Select the first report you created previously. Now save the page.
Go back to the first tab of the web pages module, and add a new page. Repeat the steps above except this time choose the second restriction you created, and when you make the link be sure to link to the second report you created. The image below is what the live white-facing pages you just made look like:
However, if you are not logged in, the page will look like this:
When you click on the 'View Report' link, the page you are taken to looks like the image below - any styling you want it to have will have to be added.
You still have to make one last web page - in this page you will link to each of the web pages that you set up previously. Click add new. Give it a link name, page title and category. In the body area of the page, type both "Blogs" and "Members". These will link to the pages you made in the previous step. Do so by highlighting them, clicking the insert link button, selecting Web Pages, and pick the appropriate web page form the previous steps. The resulting page looks like this:
The only step left is to either set up a link on the live site to the reports web page you created in the last step. Go to the menus module and add an item to the main menu which links to the web page with the 'Blogs' and 'Members' hyperlinks.
Now what appears on your live site is a link to a web page which has two links on it: 'Blogs' and 'Members'. Clicking on these will take you to a login screen unless you are logged into MyAccount on the white-facing site or logged into the back end. If you are logged in, you will be presented with a link to the report rather than a login window.
If you are logged into the back end you will not see the expected behavior because you are considered by the system to belong to every restriction group. Therefore, to test if the setup is working properly you will need to either go to the site in a private browsing window or log out of the back end before testing.