What is best way to do register without email ?

Comments

bwv’s picture

You can turn off email verification here: admin/user/settings

Look for a checkbox that says "Require e-mail verification when a visitor creates an account"

didox’s picture

ok, but users still have to write down in form their email. I don't need their email.

Is any modules which I can use ?

bwv’s picture

-Anti-’s picture

> Require e-mail verification when a visitor creates an account

But the user is still required to type an email address. This just lets them type a fake one.

There is a module called localemail which purports to switch email off completely, but I couldn't get it to work. And in any case, not having an email specified breaks modules that expect an email to be present.

So a more accurate answer to this question is that Drupal (and every other CMS out there) assume that a verified email has been registered for each user. They do not allow for scenarios where users do not have email (eg. school websites). And if you do manage to somehow register users without an address, other aspects of the system will start to throw up errors.

I would love to be proven wrong.

markross’s picture

Sorry to drag up an old thread but it seems that there was no solution to this. I am developing a site for people who have never used the internet (or are very new to it), so most will not have email addresses. I want to give people the option to register with either a mobile number or email address. The only way I have found of doing this is by writing my own registration module which saves a null to the mail field in the user table if no email address is entered. I would however prefer to be able to use the built in user module for registration, so if anyone has any ideas of a way of forcing it to accept a blank email address, please let me know!

Patroclas’s picture

This may not be what you want to hear, but I would suggest that an email address is a pre-requisite for using the internet these days. It's easy to do and is part of the 'basics'. Use of a CMS without an email address is very limiting.

markross’s picture

Ok I've found a way of doing it. I re-used some code from the localemail module http://drupal.org/project/localemail (with some slight modification to make it work in Drupal 7):

Here are the main functions that do the work:


function noemail_menu()
{
    $items = array();

    $items['user/register/noemail'] = array(
        'title' => 'Register without an email',
        'description'  => 'Register without an email',
        'page callback' => 'noemail_page',
        'access arguments' => array('access content'),
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

function noemail_page()
{
    return drupal_get_form('user_register_form');
}

function noemail_form_alter(&$form, &$form_state, $form_id)
{
    global $user;
    switch ($form_id) {
        case 'user_register_form':
            if (arg(2)=='noemail')
            {
                $form['account']['mail']['#required'] = false;
                $form['#validate'][0] = 'my_user_register_validate2';
                $form['account']['mail']['#prefix'] = '<div style="display:none">';
                $form['account']['mail']['#suffix'] = '</div>';

                $form['mail']['#required'] = false;
                $form['mail']['#prefix'] = '<div style="display:none">';
                $form['mail']['#suffix'] = '</div>';
                break;
            }
    }
}

function my_user_register_validate2($form, &$form_state) {
  // if no email value, then stuff a temp one to fool the validation
  if ($form_state['values']['mail'] == null)
  // a unique non-existent email
  $form_state['values']['mail'] = 'nobody@nowhere.com';

  // call original system validation
  user_register_validate($form, $form_state);

  // stuff empty back again
  if ($form_state['values']['mail'] == 'nobody@nowhere.com')
  $form_state['values']['mail'] = '';
  return;
}
markross’s picture

The key thing is that it passes a dummy email address (nobody@nowhere.com) to the user_register_validate function. After that it empties $form_state['values']['mail'] so that an empty string just gets written to the database.

arisaves’s picture

I've been trying to outfit the LocalEmail module for D7 with the help of coder, but I haven't been successful.

pedrosp’s picture

suscribe

arisaves’s picture

Hello all,

I think this module may be of use to you.