When creating a new account I'd love to be able to notify users that their account has been created. Unfortunately there doesn't seem to be an option to do this? Hopefully I just missed the toggle to do this?

Aside: I tried to hack a Rule together to send out an email when the accounts were first saved; however, there's a security issue open preventing the token module from allowing a one-time-login link to be created #1289898: Action: Generate a one-time-login-url. Which isn't this module's problem, except I'm not sure how else to stack together a chain of options to get the emails sent out.

CommentFileSizeAuthor
#9 at_fuep_20150212.zip4.89 KBTytooF
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zarkinfrood’s picture

Or if we could set initial password on the import as well.

I do not see the migrate module handling this any better.

There has to be a better way to manage users in bulk on the import process

Johnny vd Laar’s picture

I have created this in our custom module:

in the x.module file:


/**
 * Implements hook_ctools_plugin_api().
 */
function ezmod_ctools_plugin_api($owner, $api) {
  if ($owner == 'feeds' && $api == 'plugins') {
    return array('version' => 1);
  }
}

/**
 * Implements hook_feeds_plugins().
 */
function ezmod_feeds_plugins() {
  $path = drupal_get_path('module', 'ezmod') . '/plugins';

  $info['FeedsUserExtendedProcessor'] = array(
    'name' => 'User extended processor',
    'description' => 'Create users and send account mails.',
    'help' => 'Create users from parsed content.',
    'handler' => array(
      'parent' => 'FeedsUserProcessor',
      'class' => 'FeedsUserExtendedProcessor',
      'file' => 'FeedsUserExtendedProcessor.inc',
      'path' => $path,
    ),
  );
  return $info;
}

in the plugins/FeedsUserExtendedProcessor.inc file:


/**
 * @file
 * FeedsUserExtendedProcessor class.
 */

/**
 * Feeds processor plugin. Create users from feed items.
 */
class FeedsUserExtendedProcessor extends FeedsUserProcessor {
  /**
   * Save a user account.
   */
  protected function entitySave($account) {
    if ($this->config['defuse_mail']) {
      $account->mail = $account->mail . '_test';
    }

    $mail = FALSE;
    if (empty($account->pass)) {
      $account->pass = user_password();
      $account->password = $account->pass;
      $mail = TRUE;
    }

    user_save($account, (array) $account);
    if ($mail) {
      _user_mail_notify('register_admin_created', $account);
    }
    if ($account->uid && !empty($account->openid)) {
      $authmap = array(
        'uid' => $account->uid,
        'module' => 'openid',
        'authname' => $account->openid,
      );
      if (SAVED_UPDATED != drupal_write_record('authmap', $authmap, array('uid', 'module'))) {
        drupal_write_record('authmap', $authmap);
      }
    }
  }
}

So hopefully this will one day be merged into the feeds module :-)

jrao’s picture

See #867966: Give user importer the option to send welcome emails to new users for why this is not included by default (which I think was a mistake). A revised FeedsUserExtendedProcessor class which gives a configuration option and reuse parent's entitySave:

/**
 * @file
 * FeedsUserExtendedProcessor class.
 */

/**
 * Feeds processor plugin. Create users from feed items.
 */
class FeedsUserExtendedProcessor extends FeedsUserProcessor {
  /**
  * Override parent::configDefaults().
  */
  public function configDefaults() {
    return array(
      'send_mail' => FALSE,
    ) + parent::configDefaults();
  }

  /**
   * Override parent::configForm().
   */
  public function configForm(&$form_state) {
    $form = parent::configForm($form_state);
    $form['send_mail'] = array(
        '#type' => 'checkbox',
        '#title' => t('Send new account notification'),
        '#description' => t('This will send new account notification to newly imported users.'),
        '#default_value' => $this->config['send_mail'],
    );
    return $form;
  }

  /**
   * Save a user account.
   */
  protected function entitySave($account) {
    $mail = !$account->uid;
    parent::entitySave($account);
    if ($mail) {
      _user_mail_notify('register_admin_created', $account);
    }
  }
}
kaerast’s picture

I'd like to do a little more testing of this before releasing, but http://drupal.org/sandbox/lordrich/1701892 adds in the functionality you are missing here.

It's based on comment 2 above, and it's working on my development system, but there is no way of configuring whether it sends emails or not. It's also not been tested on our production systems.

If people would like to comaintain and/or help here then I'm sure we can get a release out soon.

FredM’s picture

It can be done much simpler I think. Just import the users with field-mapping of the Account status set to 0. Then you can unblock the new users (/admin/people) and Drupal will send an email with user confirmation to the new user.

twistor’s picture

Project: Feeds » Feeds User Extended Processor
Version: 7.x-2.0-alpha4 »
Component: Feeds Import » Code
Category: support » feature

@kaerast, I'm moving this issue over you.

It's either that, or I'm closing this as won't fix. I believe this could be done with Rules. But more importantly, I really don't want to support this. Ping me if you need any help.

kaerast’s picture

The module in my comment above is a separate module which adds a new processor which seems a messy way of doing this (and means I'd have to support that module and update it whenever the Feeds module changes). If I were to merge the extra option for email delivery into the main Feeds module, so that you get an extra option to enable email notifications, would you accept the pull request?

prakash101’s picture

Hello,

I am appreciate the above code work,But for me none of it is working.
can we send the mail using rule or something else then pls paste it.
i have created a custom module with above code but nothing happened rather than of wastage of my lot of time.

Thanks in Advance

TytooF’s picture

Issue summary: View changes
FileSize
4.89 KB

Hello,

I have to say this proposal of a module help me a lot to import my users from CSV file and to send them a welcome message.
However, I had a trouble at first to test it, and I had to add an empty echo in the "configForm" method of the FeedsUserExtendedProcessor, to have Drupal showing the new form elements... I really don't know why.

After, I had another needs, concerning more the user module, to allow me to send specific welcome message depending on Feeds Importer, and on user added role.
For my project, I choose to use the custom module I've done with your code (thanks again), to implement such need.

In the joined file, you can find the finalised module (at_fuep as AT Feeds User Extended Processor) I use today, to serve such purpose (send specific mail by import).

This module finally do :
* Add Feeds User Extended Processor (require Feeds module), with possible send mail option and specific welcome mail selector.
* Add Specific admin welcome mail for all of the site role (except Anonymous, Authenticated user and Administrator), directly manageable in the people settings (/admin/config/people/accounts), as every other mail.
* Alter the Admin register user form to change the 'send notification' checkbox with a selector (no, default, mail *Role*)
* Send selected message on admin user add and import.

Hope it could help some people.

Now I have some trouble to automate the feeds importers, but I'm still trying to solve it.

prash1485’s picture

Hello TytooF,

This is exactly what i was looking for and it's working great.

However the email that was sent is default one for every user. Somehow it is not sending modified emails for each role.

I got the settings right except: * Alter the Admin register user form to change the 'send notification' checkbox with a selector (no, default, mail *Role*)

Not able to find this one. Can you please help with this one. May be I am not looking at right path or something.

Thank you

TytooF’s picture

Hello prash1485,

I'm glad to see that this module can help someone :)

To solve your problem (default message sent to all user roles) :

  1. Be sure you have set a specific message for each roles (if not, default drupal message will be used) at /admin/config/people/accounts. You must see some more tabs > Welcome email for role "MyROLE"
  2. Test the specific message by adding manually a user at /admin/people/create: Where you normally have a checkbox to notify user, you must see a select with email options.
  3. Set your feeds importer to use User extended processor
  4. Set your feeds importer User extended processor to : Send new account notification, and select the type of notification "Mail MyROLE".

If this is not solving the problem, maybe I have to send you a new version of this module.

However the email that was sent is default one for every user. Somehow it is not sending modified emails for each role.

The module do not choose the mail to send itself on user import depending on their role. You can select witch mail to send for an importer... Then if you mixes user roles inside your file, it will not work. I use different files importer depending on the user role.

I got the settings right except: * Alter the Admin register user form to change the 'send notification' checkbox with a selector (no, default, mail *Role*)

I just mean you can choose witch specific mail to send when an administrator add a user (/admin/people/create). The module alter the user_form to do this...

prash1485’s picture

Hello Tytoof,

Thank you very much for taking effort and replying to my message in great detail.

Firstly I see the tabs on (/admin/config/people/accounts) for each user role and have modified it as per my demands.

Tested the same with manually creating a user and works perfectly by sending out right email for the that role.

Set your feeds importer User extended processor to : Send new account notification, and select the type of notification "Mail MyROLE".

Now on Feeds importer I chose User extended processor and checked all the settings that are available. I see a selection for the role to be assigned after account created but I do not see any setting for the email selection to be sent out.

So I guess as you said, its the updated module that I do not have with me. If you already have that setting in place please send it will help a lot.

Thank you

TytooF’s picture

Hello prash1485,

This is the same trouble I got when I was first developing this module... For an unknown reason, Feeds or CTools, does not see the override on the configForm method of the plugin.

I download the module from this page, and install it on a project where I was already using Feeds.
I enable the module, and create a new Feeds importer where I select the processor "User extended processor".

On the processor parameters, I do not see the 'Send new account notification' checkbox nor the 'Type of notification' select.
Off course, I try many times to clear the cache.

To solve this, I had to edit the at_fuep\plugins\FeedsUserExtendedProcessor.inc file, and I modify just a bit the configForm method.
I just comment the line 59, where there is the empty echo...
I then clear the cache again, and then the checkbox and the select appeared.

After this "hack", you'll no more have to do it, even if you delete your Feed importer and create another one.
If you try it on a local Drupal installation, you'll probably to have to do it again on your production server, except if you send your local database.

I really don't understand why I had to do this: modify the plugin inc file after the module installation...

I hope it will help ;)