🇺🇦

This module is maintained by Ukrainian developers.
Please consider supporting Ukraine in a fight for their freedom and safety of Europe.

Module provides ability:

  • Show configurable message "Login or Register to use this flag" to anonymous users instead of flag link
  • Show original flag label, on click: Display popin with message "Login or Register to use this flag", Drupal 8 version
  • Open Login and Registration form in popup (with ability to tune Login and Registration popups settings), Drupal 8 version
  • Automatically "Flag" entity with clicked flag after successful Login or Registration

Basic usage

Flag anonymous module helps you to show existing "flagging" ability to anonymous users and motivate them to login or register in a simple way (on the same page using popup).

Requirements

Installation

  • Install the module to:
    • Drupal 7: sites/all/modules/contrib or sites/all/modules
    • Drupal 8: modules/contrib or modules
      or with Composer: $ composer require 'drupal/flag_anon:^1.0'
  • Enable Flag anonymous module

Configuration (Drupal 8)

  • Go to a Flags list page /admin/structure/flags
  • Click "Edit" link on Flag which you'd like to configure
    • Or click "Add flag" button if you'd like to add a new Flag
  • Scroll down flag edit page to "Anonymous settings" section
  • Check "Show this flag to anonymous users even if they don't have permission to use it." checkbox to enable module functionality.
    • IMPORTANT NOTE: Anonymous users shouldn't have Flag/Unflag permission for currently edited flag (shouldn't be able to use this flag). If anonymous users have Flag/Unflag permission remove it using /admin/people/permissions#module-flag page, otherwise module functionality will be blocked.
  • Choose "Label display" option:
    • "Keep original flag label (show Message on click)" - in this case original flag label will be displayed. On click by it: Popin with "Login or Register to use this flag" message will be displayed.
      • Set "Dialog message title" - it's a title of Popin with "Login or Register to use this flag" message. Leave blank to have empty Popin title.
    • "Show Message instead of flag label" - in this case flag label will be replaced with "Login or Register to use this flag" message.
  • Set "Message" - it's a "Login or Register to use this flag" message. You can use: @login - Login link, @register - Registration link placeholders there.
  • Set "Login link label" - a label for Login link placeholder.
  • Set "Register link label" - a label for Registration link placeholder.
  • Check "Show Login and Registration form in popup." checkbox if you'd like to show Login and Registration forms in Popup on click by "Login" or "Register" links
    • "Login popup settings" - Login popup settings for data-dialog-options attribute. Valid JSON should be used like: {"width": "auto"}
    • "Register popup settings" - Registration popup settings for data-dialog-options attribute. Valid JSON should be used like: {"width": "auto"}
  • Fill or change other needed fields and click "Save Flag" button.

For developers

To add custom placeholders into configurable "Login or Register to use this flag" message implement hook_flag_anon_message_placeholders_alter() and add additional placeholders there (see more details in flag_anon.api.php file).

Supporting organizations: 

Project information

Releases