The Enforce Profile Field is a new module which allows editors to enforce the completion of one or more fields in order to access content on a site. It is now available for Drupal 8.
Sometimes you need to collect a variety of profile data for different users. The data may be needed for regulatory compliance or marketing reasons. In some cases you need a single field and in others it may be several. You may also wish to collect the information when a user access certain parts of the site.
The Enforce Profile Field module comes to the rescue in cases such as these, forcing users to complete their profile before being able to move onto the page they want to see. This may sound harsh, however, collecting data as you need it is a more subtle way of collecting data than enforcing it all at registration time.
The implementation consists mainly from a new Field Type called "Enforce profile" and hook_entity_view_alter().
The module works as follows
- Site builder defines a “form display” for the user type bundle and specify fields associated with it to collect data.
- The fields should not be required, as this allows the user to skip them on registration and profile editing.
- In addition the Form Mode Manager module can be used to display the “form display” as a "tab" on a user profile page.
- The site builder places an Enforce profile field onto an entity type bundle, such as a node article or page.
- The Enforce profile field requires some settings:
- A "User's form mode" to be utilized for additional field information extraction (created in the first step).
- An "Enforced view modes" that require some profile data to be filled in before being able to access them. You should usually select the "Full content" view mode and rather not include view modes like "Teaser" or "Search".
- The editor creates content, an article or page, and can then select which fields need to be enforced.
- The editor is provided with multi-select of "User's form mode" fields.
- Selecting nothing is equal to no access change, no profile data enforcement.
- A new user navigates to the content and is redirected to the profile tab and is informed that they need to complete the fields.
- Fields are completed, form submitted and the user redirected back to the content.
- In case the user doesn't provide all enforced fields, the profile tab is displayed again with the message what fields need to be filled in.
Why to use the Enforce Profile Field to collect an additional profile data?
- You may need customer's information to generate a coupon or access token.
- You may just want to know better with whom you share information.
- Your users know exactly what content requires their additional profile data input rather than satisfying a wide range of requirements during registration. It just makes it easier for them.
- The new profile data can be synced to a CRM or other system if required to.
Let us know what you think.