Hi,
I created a custom registration form with chronoform... Now I need to have it automatically login registration.
I'm thinking I need to put this code in the after on submit code field.. I'm on J! 1.5.8.
But it doesn't work.. Is it possible?
Thanks.
I created a custom registration form with chronoform... Now I need to have it automatically login registration.
I'm thinking I need to put this code in the after on submit code field.. I'm on J! 1.5.8.
<?
global $mainframe;
$usersipass['username'] = JRequest::getVar('username');
$usersipass['password'] = JRequest::getVar('pass');
$mainframe->login($usersipass);
//redirects to another page.... not sure what J! function does this.
header (Location: "/index.php");
?>
But it doesn't work.. Is it possible?
Thanks.
i found the error... this works
<?
global $mainframe;
$usersipass['username'] = JRequest::getVar('username');
$usersipass['password'] = JRequest::getVar('pass');
$mainframe->login($usersipass);
//redirects to another page.... not sure what J! function does this.
header ('Location: /index.php');
?>
Glad you made it, thanks for posting the working code!
Regards,
Max
Regards,
Max
Hi peptobismol,
If you want to stay with the Joomla code the missing piece is $mainframe->redirect($link, $message, $type); where $message and type are optional. $message will display a system message aftet the redirect, $type sets the format of the message - from memory the options are ('info', 'alert', and 'error').
Bob
If you want to stay with the Joomla code the missing piece is $mainframe->redirect($link, $message, $type); where $message and type are optional. $message will display a system message aftet the redirect, $type sets the format of the message - from memory the options are ('info', 'alert', and 'error').
Bob
Hi,
there's a problem with my thinking with this code..
If a new user registers with an existing user name, it should throw an error and the code redirects without registering or throwing an error.
The Joomla registration plugin doesn't throw errors?
Any insights would be appreciated.
there's a problem with my thinking with this code..
If a new user registers with an existing user name, it should throw an error and the code redirects without registering or throwing an error.
The Joomla registration plugin doesn't throw errors?
Any insights would be appreciated.
this is what I have.. I guess it's working but not sure if it is kosher. It would be nice to print out an error message but not sure how in joomla.. Best I can do is redirect to a page.
onSubmit before email
onSubmit after email
onSubmit before email
<?
global $mainframe;
//check for existing username
$usersipass['username'] = JRequest::getVar('username');
$usersipass['password'] = JRequest::getVar('pass');
$email = JRequest::getVar('email');
$db =& JFactory::getDBO();
$query = 'SELECT `id`'
. ' FROM #__users'
. ' WHERE username=' . $db->quote( $usersipass['username'] );
$db->setQuery( $query );
$result = $db->loadResult();
if ($result) {
//user already exists
$link = '/index.php?option=com_content&view=article&id=86';
$mainframe->redirect($link,'User already exists', 'error');
}
//check for existing email
$query = 'SELECT `id`'
. ' FROM #__users'
. ' WHERE email=' . $db->quote( $email );
$db->setQuery( $query );
$result = $db->loadResult();
if ($result) {
//user already exists
$link = '/index.php?option=com_content&view=article&id=86';
$mainframe->redirect($link,'Email already exists', 'error');
}
?>
onSubmit after email
<?
global $mainframe;
$usersipass['username'] = JRequest::getVar('username');
$usersipass['password'] = JRequest::getVar('pass');
$mainframe->login($usersipass);
$link = '/index.php?option=com_content&view=article&id=72:awards-poll&catid=9:voting&Itemid=52';
$mainframe->redirect($link);
?>
HI peptobismol,
That first check is a validation - it could go into the ServerSide validation box.
Bob
That first check is a validation - it could go into the ServerSide validation box.
Bob
oh yeah,
I forgot about that box. Thanks,
I forgot about that box. Thanks,
This topic is locked and no more replies can be posted.