3 days I've been banging my head on this thing now lol.
I've gotten the rest of the ajax functions built and working fine in the controller class including using the editUser function where store() works just fine, a searchUsers function that works great, and a deleteUser function that works fine.
Here's what I have at this point for this registerUser function in the controller class:
Code:
class membermanagerController extends JControllerLegacy
{
// REGISTERATION USER
public function registerUser($name, $email, $password, $address, $address2, $city, $state, $zip, $phone, $website, $facebook, $hours, $category, $approve = 0, $confirm = 0)
{
global $_CB_framework, $mainframe, $_CB_database, $ueConfig, $_PLUGINS;
if (defined('JPATH_ADMINISTRATOR')) {
if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed!';
return;
}
include_once(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php');
} else {
if (!file_exists($mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed!';
return;
}
include_once($mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php');
}
cbimport('cb.database');
cbimport('cb.html');
cbimport('cb.plugins');
$approval = ($approve == 2 ? $ueConfig['reg_admin_approval'] : $approve);
$confirmation = ($confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm);
$usertype = $_CB_framework->getCfg('new_usertype');
$user = new moscomprofilerUser($_CB_database);
$user->usertype = ($usertype ? $usertype : 'Registered');
$user->gid = $_CB_framework->acl->get_group_id($user->usertype, 'ARO');
$user->gids = array($user->gid);
$user->sendEmail = 0;
$user->registerDate = date('Y-m-d H:i:s', $_CB_framework->now());
$user->name = $name;
$user->username = $email;
$user->email = $email;
$user->password = $user->hashAndSaltPassword($password);
$user->cb_address = $address;
$user->cb_address2 = $address2;
$user->cb_city = $city;
$user->cb_state = $state;
$user->cb_zip = $zip;
$user->cb_phone = $phone;
$user->cb_website = $website;
$user->cb_facebook = $facebook;
$user->cb_hours = $hours;
$user->cb_category = $category;
$user->registeripaddr = cbGetIPlist();
if ($approval == 0) {
$user->approved = 1;
} else {
$user->approved = 0;
}
if ($confirmation == 0) {
$user->confirmed = 1;
} else {
$user->confirmed = 0;
}
if (($user->confirmed == 1) && ($user->approved == 1)) {
$user->block = 0;
} else {
$user->block = 1;
}
$_PLUGINS->trigger('onBeforeUserRegistration', array(&$user, &$user));
if ($user->store()) {
if (($user->confirmed == 0) && ($confirmation !== 0)) {
$user->_setActivationCode();
if (!$user->store()) {
echo '<div class="error_notice">Registration Failed!</div>';
return false;
}
}
$_PLUGINS->trigger('onAfterUserRegistration', array(&$user, &$user, true));
echo $name . ' successfully added!';
return true;
} else {
echo '<div class="error_notice">Registration Failed!</div>';
return false;
}
return false;
}
public function addMember() {
// GET VALUES
$jinput = JFactory::getApplication()->input;
$name = $jinput->get('name');
$email = $jinput->get('email');
$password = $jinput->get('password');
$address = $jinput->get('address');
$address2 = $jinput->get('address2');
$city = $jinput->get('city');
$state = $jinput->get('state');
$zip = $jinput->get('zip');
$phone = $jinput->get('phone');
$website = $jinput->get('website');
$facebook = $jinput->get('facebook');
$hours = $jinput->get('hours');
$category = $jinput->get('category');
self::registerUser($name, $email, $password, $address, $address2, $city, $state, $zip, $phone, $website, $facebook, $hours, $category);
}
}
I've tried stripping it down to it's bare essentials by removing all of the extra fields and it still doesn't work. I've verified that all of the values are being passed. I've var_dumped the $user object to ensure that it's being created properly. I've set break points all the way down through the function and it all seems to be perfectly fine, it just simply won't store the user object in the db.
The really baffling thing is if I use this function outside of the controller/ajax method it works fine. I'm convinced there's a ghost in the machine at this point lol.