Chuyển đến nội dung

Bài 36 · Projects and Practice

Project: A Members-Only Resource Site

Build a members-only resource library in Joomla: groups, custom access levels, registration, protected categories, login redirects, private downloads and an access test matrix.

Many real Joomla sites are not brochures: they are clubs, schools, associations or companies that share material with a defined group. In this project you design a members-only resource library for an imaginary photography club, Focus Club. Public visitors see a home page and a sign-up page. Members see tutorials and a gallery. Club leaders also see internal minutes. One person manages everything.

The project joins accounts, viewing levels, permissions and registration and privacy. Joomla cannot run on this site, so you get a build guide with exact paths and two JavaScript or PHP stand-ins: an access test matrix and a signed, expiring download link, which addresses a limit that surprises many site builders.

Step 1: Requirements

Audience Sees Does
Visitors (guests) Home, About, Join Register or log in
Members Tutorials, Gallery Read; comment through an extension if desired
Leaders Minutes (internal) Edit tutorials
Webmaster Everything Administration

Step 2: Groups and levels

Create the groups in Users > Groups:

  • Members, parent Registered.
  • Leaders, parent Editor (so leaders can edit articles and inherit Registered).

Create viewing levels in Users > Access Levels:

  • Members area: groups Members and Leaders.
  • Leaders only: group Leaders.

Do not change the default groups or levels; add yours next to them. Remember the inheritance rule: Leaders has Editor and Registered above it, so it can also see items for those.

flowchart TD
    Public --> Registered
    Registered --> Members
    Registered --> Author --> Editor --> Leaders
    Public --> Guest

The new groups sit in the tree; Leaders inherits editor rights.

Step 3: Content and menus

  1. Categories (Content > Categories): Tutorials (Access: Members area), Gallery (Members area), Minutes (Leaders only), Pages (Public).
  2. Articles: public About and Join pages in Pages; a few tutorials and gallery posts; two minutes.
  3. Menus: a Main Menu with Home, About, Join (Public); Tutorials, Gallery (Access: Members area); Minutes (Leaders only). The Access of the menu item hides the link; the Access of the category and articles protects the content itself. Set both.
  4. A Login module (Access Public or Guest) in the sidebar, with Login Redirect to the Tutorials menu item. A Logout link or the module's logout form for members.

Step 4: Registration

In Users > Manage > Options: allow registration, the New User Registration Group = Members, Activation = Administrator (the club reviews applicants) or Self plus captcha for open clubs. Add the User - Terms and Conditions and Privacy Consent plugins pointing at the privacy article, and set up a Registration menu item for the Join page. Test the whole flow with a new browser profile.

Step 5: Permissions

Leaders need to edit tutorials in the front end. In Content > Options > Permissions (or on the Tutorials category, which is more precise) allow Create, Edit and Edit State for Leaders, and nothing for Members. Members read; Leaders write; only the webmaster (Super Users) changes configuration. Test with real accounts, not assumptions.

Step 6: Test the access matrix

Write the expected behavior as a table and check it. The stand-in below encodes the groups and levels from this project and prints who sees what.

JS Access matrix test

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change a level or a parent and re-run the table to see which expectations break. In Joomla you would repeat this test by logging in as each kind of user.

Step 7: Protecting downloads

Here is the trap. Access levels protect Joomla pages, not files. If you upload a PDF to the Media folder (/images/...) it has a public URL, and anyone who knows or guesses it can download it, logged in or not. Options:

  1. Keep private files outside the web root and serve them through a component or extension that checks the user's access before sending the file. This is the correct approach for anything sensitive.
  2. Use a download manager extension that stores files privately and honors Joomla access levels.
  3. At the web server, protect a folder (for example with basic auth or authenticated request rules), accepting that it is separate from Joomla accounts.
  4. For low-sensitivity material, accept the public URL but do not link it publicly.

A common technique is a signed, expiring link: the server creates a URL containing an expiry time and a signature (an HMAC with a secret key). The download script verifies the signature and time before sending the file. This stand-in shows the idea in plain PHP.

PHP Signed, expiring download links

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

This is a concept stand-in. A real implementation also checks the user's Joomla access level on the server, streams the file with correct headers and logs the download.

Step 8: Privacy and housekeeping

  • Add a privacy policy article and link it in the footer and registration.
  • Plan how members can export or delete their data through Users > Privacy.
  • Decide how long inactive accounts are kept and clear them.
  • Require MFA for Leaders and the webmaster.
  • Check the User Actions Log after testing to see the trail.

Step 9: Going further

  • Add custom fields to user profiles (membership number, interests).
  • Add a multilingual version (Multilingual Sites).
  • Use the API to sync members with a mailing list (Web Services API and CLI).
  • Make sure nothing private appears in search results: search indexing respects access levels, but test it as a guest.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which two settings together hide a members-only article from guests?

    Set Access on the menu item (hides the link) and on the category or article (protects the content).
  2. 2. A PDF is uploaded to the images folder in a Registered-only article. Who can download it?

    Access levels protect Joomla pages, not static files served directly by the web server.
  3. 3. What does the signature in a signed link prevent?

    Changing any signed part invalidates the HMAC, so the server refuses the request.
  4. 4. Which parent group makes sense for a new Leaders group that must edit articles?

    Leaders inherits editing rights from Editor without needing Super User access.

Summary

  • Design groups and levels first; add your own beside the defaults.
  • Protect both menu items and content with Access; test with a matrix and real accounts.
  • Registration needs the right default group, activation mode, consent and mail.
  • Access levels do not protect files: use private storage and server-side checks or signed links.
  • Add MFA and a privacy workflow for people who hold powerful roles.

Next: Launch Checklist and Maintenance

Theo dõi tiến độ của bạn

Tạo tài khoản miễn phí để đánh dấu bài đã học và tiếp tục từ chỗ bạn dừng lại trên mọi thiết bị.