Programatically create user that needs admin aproval When creating a new user with user_save, it seems to get the "approved" role automatically, even though I pass an empty array to $user-&gt;roles.

How can I force the programatically created user to need admin approval before being activated?
Step1

Not need to follow it compulsary

You don't need any third-party modules. Drupal core has the option to verify the email the user enters, and the option for the administrator user to approve the accounts users create. In Drupal 7, those settings are on /admin/config/people/accounts.


Step2



Once you prepare your $user object and use it on user_save function you have to follow below steps to send the mail.




$userData = user_save($user);
$account = user_load($userData-&gt;uid);
$op = 'register_pending_approval';
$status = _user_mail_notify($op, $account);