Flashpoint Access Code
How it works
Flashpoint Access Code provides an access method for Flashpoint Courses, which allows you to grant access by possessing a cookie whose value is set to a pre-defined code.
Enroll vs. View Access
Access codes work on a per-course basis, and further grant either enroll or view access, but not both.
Usage
You may specify a maximum number of usages for a given code, or 0 for unlimited. In Views, there is also a field for rendering the number of times a code has been used.
Usage is recorded via the creation of a FlashpointAccessCodeUsage entity, which will record the user or IP, the access code redeemed, and the course. You can generate reports from this data using Views.
Methods of redemption
Redemption form
If you use the "Flashpoint Access Code: Show redemption form" access method, a link to a form will be generated, and this form will allow someone to redeem an access code. If it is an enroll code, logged-in users will be enrolled automatically. If it is a view code, a cookie value will be set, and the user directed back to the course page.
URL
URLs are patterned '/flashpoint-access/{group}/{code}' , where the group is the numeric ID of the group, and the code is the text of the code being redeemed. Combined with URL aliases, you can create custom URLs that automatically grant access.
Setting up view access for Anonymous users
This module is known to have some issues with granting view access for anonymous users, due to page caching creating unpredictable results. If you are planning to use access codes with anonymous users, or otherwise run into caching-related issues, follow these steps:
- For Anonymous, turn off the Internal Page Cache module, as it forces caching on a per-page basis for Anonymous users. Internal Dynamic Page Cache may be left on.
- In your sites/[site]/services.yml file, you will need to add the 'cookies:Drupal_visitor_flashpoint_access_code' cache context into your renderer.config settings:
parameters:
renderer.config:
# leave the other cache contexts alone - just add our cookie context
required_cache_contexts: ['other', 'cache', 'contexts', 'cookies:Drupal_visitor_flashpoint_access_code']Access codes should behave as expected at this point.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion