1

I have set up a flag so that users can flag certain types of nodes and receive an email notification if there is any activity on it, such as comments. It's paired with the answers module. What I can't figure out how to do is make is so that authors are automatically subscribed to those types of nodes that they author. Other associated modules are message_subscribe, flag_actions, message_subscribe_email,

Using flags version 7.x-3.9. Let me know if I left out any pertinent information.

6
  • You want to automatically enable the flag for the author, or you want to subscribe the author independent of the flag? Sep 8, 2017 at 9:43
  • I want to subscribe the author automatically, or allow author to subscribe to their node. The flag is already available to all logged in users.
    – Christia
    Sep 8, 2017 at 9:54
  • Is it correct to assume that anonymous users are NOT allowed to post such types of nodes? Also, do you mean nodes of type "Question", or "Answers"? Sep 8, 2017 at 10:11
  • All authenticated users can flag a question and all authenticated users can ask a question or provide an answer.
    – Christia
    Sep 8, 2017 at 10:13
  • Sorry @Christia but (1) what about anonymous users? and (2) should that auto-subscribe apply to questions, answers or both? Sep 8, 2017 at 10:22

2 Answers 2

2

For the Answers module (you know the dril: I'm a co-maintainer ...) to function, you must have the Rules module enabled also.

Therefor, have a look at this rule (in Rules export format, use the Rules UI to import it in your own site):

{ "rules_subscribe_question_author_automatically" : {
    "LABEL" : "Subscribe question author automatically",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag", "rules" ],
    "ON" : { "node_insert--answers_question" : { "bundle" : "answers_question" } },
    "DO" : [
      { "flag_flagnode" : {
          "flag" : "subscribe_answers_notifications",
          "node" : [ "node" ],
          "flagging_user" : [ "site:current-user" ],
          "permission_check" : "1"
        }
      },
      { "drupal_message" : { "message" : "You\u0027ve been subscribed to your own post automatically (use the unsubscribe link if that\u0027s not what you want)." } }
    ]
  }
}

For those who are not an expert in Rules-ese, this is what the above rule will do:

  • Rules Event: after saving a new node of type "Question".
  • Rules Actions:

    • flag that node by the user who created it, by the flag with machine name subscribe_answers_notifications (which by accident is exactly also what happens if a user manually clicks the "subscribe" link (below the question).
    • Show an informational message like "You've been subscribed to your own post automatically (use the unsubscribe link if that's not what you want)."

I think this Answers (oeps: answers) the question ... which was "... authors are automatically subscribed to those types of nodes that they author ..."

Notes:

  • in case some author does not want to be subscribed to a question author by that author, it is still possible to use the unsubscribe link (typically bottom right below the question) after they created their question (node).
  • the above rule only applies to nodes of type "Question", though with a minor improvement you could as well make it work for type "Answer".
3
  • Nice! This works too and does answer my question more exactly than the answer I provided. Hopefully other users will benefit from both. Thanks again!
    – Christia
    Sep 8, 2017 at 10:02
  • 1
    @Christia ... May I say "What else did you expect"? Actually I might add this rule (I just invented) as an extra (disabled by default) rule to the Answers module some day ... Sep 8, 2017 at 10:05
  • Thanks for providing this! I have rules enabled but there are no rules in it yet even after I got Answers up and running. I'll give it a try.
    – Christia
    Sep 8, 2017 at 10:18
0

The flag settings at admin/structure/flags allow you to specify, per flag, if you want to provide a checkbox on the node add form. Once that is selected, then within the content type settings that the flag is available for, you can specify a default for the checkbox to be selected or not.

This effectively automatically subscribes users to the content they are adding but also allows them to deselect it before they submit the node.

The only problem with this is if you have tried to disable the display of publishing settings in order to simplify the form for a block, it looks ugly.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.