Hi, is it possible to send email notification to mentioned user after she's been mentioned?

Comments

tanius’s picture

I do not think this is supported out of the box, since there is no Rules integration for ckeditor_mentions, and no configuration settings that would support it directly.

However, I have found a workaround for my own purposes (using the 7.x-1.2 version, but it probably also works on Drupal 6.x). For that, I simply installed the mentions module additionally and configured it to recognize usernames based on an @ prefix (config settings: prefix "@", suffix nothing). Then I created a Rule (using rules) for sending a new message, triggered by event "Mention: New Mention Created".

While this solution is admittedly hacky, the two modules do not seem to interfere in any way.

askibinski’s picture

Version: 6.x-1.0 » 7.x-1.x-dev

Indeed this module has no built-in support for email notifications.

tanius suggestion is a bit hackish indeed ;) but that might be the easiest way if you are not a programmer.

Anyway, the way we did this, was by parsing the field in our own custom module who did a lot of other things too.
Here's a code snippet to get an array of uids from a given field:

function my_node_processor($node) {
  if($node->type == 'your_node_type'){
    $uids = array();
    $DOM = new DOMDocument;
    $DOM->loadHTML($node->field_your_field[LANGUAGE_NONE][0]['value'] && "" != $node->field_your_field[LANGUAGE_NONE][0]['value']); 
    $anchors = $DOM->getElementsByTagName('a');
    for ($i = 0; $i < $anchors->length; $i++) {
      if ($anchors->item($i)->nodeValue[0] == '@') {
        $parts = explode('/', $anchors->item($i)->getAttribute('href'));
        if (is_array($parts) && count($parts) == 3) {
          if ($parts[1] == 'user') {
            $uids[] = $parts[2];
          }
        }
      } 
    }
    $uids = array_unique($uids);

   // here you should loop through the uids, load the user and send mails!

You could call this from hook_node_insert() for example.

askibinski’s picture

Status: Active » Closed (works as designed)

I'm closing this one because it's already supported in the Drupal 8 version through events, and the Drupal 7 version won't get any new features.

You can write your own email logic which is triggered by one of the events available, but the email functionality itself does not belong in this module.