I am creating a new user using this data:
jimport('joomla.application.component.helper');
$params = 'com_users';
$usersParams = JComponentHelper::getParams($params);
$new_user = JFactory::getUser(0);
$config = JComponentHelper::getParams('com_users');
$defaultUserGroup = $config->get('new_usertype', 2);
$jdata = array(
"name" => $name,
"username" => $email,
"password" => $password,
"password2" => $password,
"email" => $email,
"sendEmail" => 1,
"groups" => array($defaultUserGroup)
);
$useractivation = $usersParams->get('useractivation');
if ($useractivation === 1) {
jimport('joomla.user.helper');
$jdata['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
$jdata['block'] = 1; // block the user
} else {
$jdata['block'] = 0; // don't block the user
}
//Write to database
if (!$new_user->bind($jdata)) {
throw new Exception("Could not bind data. Error: " . $new_user->getError());
return false;
}
if (!$new_user->save()) {
throw new Exception("Could not save user. Error: " . $new_user->getError());
return false;
}
This works perfectly, but the new users are created with the "Receive System Emails" set to yes which means all new users are getting the admin emails. How can I disable this feature when creating a new user this way?