2

I was wondering if there is a way to convert SimpleNews subscribers into actual Drupal users?

Currently, I have something similar going on using custom fields in the user-register form, but wanted to know if I can leverage the Simplenews module for my needs.

I want to create a block where users can register to receive weekly e-mails in which they receive information about our weekly ad.

Cheers,

Elm

2 Answers 2

0

this may be useful http://bouteillenicolas.com/expertise-drupal/simplenews-save-subscribers-info

All you have to do is use rules, create a webform, and then use rules that handdles that webform and create the suscriber and the the user using the information sended through the webform

0

From the simplenews api:

/**
 * Act after a new subscriber has been created.
 *
 * @ingroup subscriber
 */
function hook_simplenews_subscriber_insert($subscriber) {

}

This is a hook function that is executed every time there is a new subscriber. You must use this function in your module replacing 'hook' by your module name. Try the following code:

/**
 * Implements hook_simplenews_subscriber_insert().
 *
 */
function mymodule_simplenews_subscriber_insert($subscriber) {
  $user = new stdClass();
  $user->name = 'happyUser';
  $user->mail = $subscriber->mail;
  $user->pass = 'password';
  $user->status = 1; // omit this line to block this user at creation
  // save the user
  $user = user_save($user);
  // connect the subscriber with the user
  $subscriber->uid = $user->uid;
  simplenews_subscriber_save($subscriber);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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