Programmatic user registration not forcing user to activate account I'm manually creating a user and then sending a notification email as follows:

$new_user = array(
  'name' =&gt; $username,
  'pass' =&gt; $password, 
  'mail' =&gt; $email,
  'status' =&gt; 1,
  'init' =&gt; $email,
);            

$account = user_save(drupal_anonymous_user(), $new_user);
 _user_mail_notify('register_no_approval_required', $account);  


However, the user is able to login right away. How can I enforce account activation? I have it enabled in the admin panel
You can use the LoginToboggan Prevent preauth module is available for Drupal 6 and 7.
And it realy does all the stuff. We can have "Email account activation without admin approval and also a user set password".

Code:

    $new_user = array(
      'name' =&gt; $username,
      'pass' =&gt; $password, 
      'mail' =&gt; $email,
      'status' =&gt; 1,
      'init' =&gt; $email,
      'roles' =&gt; array(logintoboggan_validating_id() =&gt; TRUE)
    );  
   $account = user_save(NULL, $new_user);
   // Send mail with account confirmation
   _user_mail_notify('register_no_approval_required', $account);


P.S. Don't forgot to uncheck 'Immediate login' option.