How to implement a follow author (or user) function? Is it possible to implement a Follow button for authors of posts in Drupal 7, so that users can:


Follow any one they wish, and
Be notified about the new posts of those authors.


This sounds like 'Mashable Follow button' for authors.

Do you have any suggestions about how to implement this?
Minimal solution

The Notifications module currently only has an Alfa version for D7 (which is this question is about), which dates from Dec 2011.

Therefor, use the Flag module as an alternative. So that users can "flag" authors they want to "follow". You'd want to use a flag related to entity "users", which is a non-global flag. Probably defined with a label like "Follow Author" (to 'flag' an author) and "Unfollow Author" (to undo a previously flagged Author).

Combine this with using the Rules module to send eMails whenever content gets updated by some author. Whereas the eMails are sent to all users who "flagged" that author (= the users who indicated they wanted to "follow" that author). If you'd only want to send such eMails for a subset of content that's being updated (eg only for selected content types), then it's just a matter of adding an appropriate extra "condition" to your rule.

Improved solution

Optionally you may also want to consider the Message module for more options in the area of sending some type of notifications. For this, you need a flag like described above (say with machine name follow).

On top of that you need a Message type and a custom Rule, both are detailed below. And you probably also want to add a custom View of those messages.

Message type

Below is an export of "a" Message type that you could use to get started (by simply importing it in your own site). It defines the message to be created when a user is flagged and it actually works together with the custom rule below. This message type has machine name user_following, and uses a replacement token like @following_user (adapt both to fit your needs, eg change @following_user to @user_who_flagged if you prefer):

{
  "name" : "user_following",
  "description" : "User following",
  "argument_keys" : [ "@following_user" ],
  "argument" : [],
  "category" : "message_type",
  "data" : {
    "token options" : { "clear" : 0 },
    "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" }
  },
  "language" : "",
  "arguments" : null,
  "message_text" : { "und" : [
      {
        "value" : "@following_user started following [message:user:name]",
        "format" : "plain_text",
        "safe_value" : "\u003Cp\u003E@following_user started following [message:user:name]\u003C\/p\u003E\n"
      }
    ]
  },
  "rdf_mapping" : []
}


This Message type (compare to a Content type ...) will be used to create Messages (compare to Nodes) that will look as in this example:


  Hillary.Trump started following Donald.Clinton


To avoid confusion, note that [message:user:name] in the message type sample above is the user to which the Message is targeted, not the flagging user!

Custom Rule

Here is a rule (in Rules Export format) which creates a message when a user is flagged:

{ "rules_somebody_started_following_you" : {
    "LABEL" : "Somebody started following you",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "user" ],
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_follow" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "user_following",
            "param_user" : [ "flagged-user" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:arguments:following-user" ],
          "value" : "[site:current-user]"
        }
      }
    ]
  }
}


Some more details about this rule:


Its purpose is to deliver a message (using the Message module) to a user being flagged (using the Flag module).
It is triggered after a user is flagged with the flag with machine name follow.
It creates a Message with machine name user_following.
It makes a variable with machine name following_user available as a replacement token for the message to be created ... so that the "flagging user" (= [site:current-user] when the flagging happens) can also be included in the message to be created.


Custom view

With the above rule and message type, you'll have "messages" that get created ... "So what?" you may think. Well, since all this is entity API based, you can create a custom view (using Views) to visualize these messages, e.g. shown via a path like /user/nid/messages. Whereas the only limitation for such Views is your own imagination (you could even create the Charts about those Messages (eg by originating user, by date, etc).

Additional info

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework. Possibly also the similar set of 8 video tutorials about the Flag module.

For more details about the Message module, refer to some interesting Use Cases detailed within its Community Documentation. And/or checkout the video introduction "Your Drupal site can talk" (if you want you can fast forward to about 03:30 where it really starts).

Note: this approach can be used also for any type of users (not just for "authors").