Skip to main content

joomla 1.7 user registration customization issue



-> i want to try new user registration customization.





-> for that i create form and call hidden variable through function from controller.





-> in controller save function i write this code but some function which not work in 1.7 so create problem here.







function register_save()

{



global $mainframe;

$db =& JFactory::getDBO();

// Check for request forgeries

JRequest::checkToken() or jexit( 'Invalid Token' );



//clean request

$post = JRequest::get( 'post' );

$post['username'] = JRequest::getVar('username', '', 'post', 'username');

$post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);

$post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);



// get the redirect

$return = JURI::base();



// do a password safety check

if(strlen($post['password']) || strlen($post['password2'])) { // so that "0" can be used as password e.g.

if($post['password'] != $post['password2']) {

$msg = JText::_('PASSWORD NOT MATCH');

// something is wrong. we are redirecting back to edit form.

// TODO: HTTP_REFERER should be replaced with a base64 encoded form field in a later release

$return = str_replace(array('"', '<', '>', "'"), '', @$_SERVER['HTTP_REFERER']);

if (empty($return) || !JURI::isInternal($return)) {

$return = JURI::base();

}

$this->setRedirect($return, $msg, 'error');

return false;

}

}



// Get required system objects

$user = clone(JFactory::getUser());

$pathway = JFactory::getApplication();

//$pathway =& $mainframe->getPathway();

$config =& JFactory::getConfig();

//print_r($config)."<br>";

$authorize =& JFactory::getACL();

//print_r($authorize)."<br>"; /// some mistake here

$newUsertype = 'Registered';



// Bind the post array to the user object

if (!$user->bind( JRequest::get('post'), 'usertype' )) {

JError::raiseError( 500, $user->getError());

}

// Set some initial user values

$user->set('id', 0);

$user->set('usertype', $newUsertype);



$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));



$date =& JFactory::getDate();

$user->set('registerDate', $date->toMySQL());



// If user activation is turned on, we need to set the activation information



jimport('joomla.user.helper');

$user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) );

$user->set('block', '1');



// If there was an error with registration, set the message and display form



if ( !$user->save() )

{

JError::raiseWarning('', JText::_( $user->getError()));

$this->register();

return false;

}



$obj1 = new stdClass();

$obj1->userid = $user->id;

$obj1->points = 0;

$obj1->posted_on = $date->toMySQL();

$obj1->avatar = '';

$obj1->thumb = '';

$obj1->params = 'notifyEmailSystem=1

privacyProfileView=0

privacyPhotoView=0

privacyFriendsView=0

privacyVideoView=1

notifyEmailMessage=1

notifyEmailApps=1

notifyWallComment=0';

$db->insertObject('#__community_users', $obj1, 'userid');



$extra_field = array(1=>2,2=>3,3=>4,4=>6,5=>7,6=>8,7=>9,8=>10,9=>11,10=>12,11=>14,12=>15,13=>16);

$i = 1;

$obj2 = new stdClass();

while($extra_field[$i] != "")

{

$obj2->id = '';

$obj2->user_id = $user->id;

$obj2->field_id = $extra_field[$i];

$obj2->value = '';

$db->insertObject('#__community_fields_values', $obj2, 'id');

$i++;

}

////////// end of joomsocial customisation///////////////////////////

// Send registration confirmation mail

$password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);

$password = preg_replace('/[\x00-\x1F\x7F]/', '', $password); //Disallow control chars in the email

UserControllerRegister::_sendMail($user, $password);



// Everything went fine, set relevant message depending upon user activation state and display message



$message = JText::_( 'Your account has been created and an activation link has been sent to the e-mail address you entered. Note that you must activate the account by clicking on the activation link when you get the e-mail before you can login.' );



$this->setRedirect('index.php', $message);

}







please help me.


Comments

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.