Skip to content

Instantly share code, notes, and snippets.

@CB9TOIIIA
Created July 7, 2018 16:30
Show Gist options
  • Save CB9TOIIIA/1867d320b5fd79364014f8f3a61d73cb to your computer and use it in GitHub Desktop.
Save CB9TOIIIA/1867d320b5fd79364014f8f3a61d73cb to your computer and use it in GitHub Desktop.
Reg Emerald User
$fname = $post['first_name'];
$lname = $post['last_name'];
$email = $post['email'];
$db = JFactory::getDbo();
$db->setQuery("SELECT * FROM #__users WHERE email = '{$email}'");
$user = $db->loadObject();
if(!$user)
{
$login = substr($email, 0, strpos($email, '@'));
$db->setQuery("SELECT id FROM #__users WHERE username = '" . $db->escape($login) . "'");
$user = $db->loadObject();
if(!empty($user->id))
{
$login = $login + $user->id;
}
$pwd = substr(md5($email . $fname . time()), 0, 6);
$data['name'] = $fname . ' ' . $lname;
$data['username'] = $login;
$data['email1'] = $email;
$data['email2'] = $email;
$data['password1'] = $pwd;
$data['password2'] = $pwd;
JFactory::getLanguage()->load('com_users');
JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_users/models');
$model = JModelLegacy::getInstance('Registration', 'UsersModel');
$return = $model->register($data);
$this->_log("new user: " . print_r($data, TRUE));
//$db->setQuery("UPDATE #__users SET `block` = 0, `activation` = '' WHERE email = '{$email}'");
//$db->query();
}
$db->setQuery("SELECT * FROM #__users WHERE email = '{$email}'");
$user = $db->loadObject();
if(empty($conversion[$post['product_id']]))
{
$this->_log("This product not found in conversion array");
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment