Forums

Auto Login and Generated password does not work.

MSOlhao 29 May, 2010
Hello, i am having a problem with Joomla Registration Plugin.
I created a form with 3 fields (Username, Email, Confirm Email), the password is generated with "Create Password" feature.
Now were's is my plugin configs.




The registration goes well, but the autologin doesn't work.
Help me please.😢
nml375 29 May, 2010
Hi,
Did you set up Joomla to require Account Activation (in the Site Configuration)? Auto-Login will not work with this enabled, since you cannot logon until the account has been activated..

/Fredrik
MSOlhao 29 May, 2010
No, the account activation is disabled.
nml375 29 May, 2010
Hi again,
Just dug around in the plugin code, and it seems the auto-login feature will not work with automatically generated passwords. I think the following change should do the trick though (in com_chronocontact/plugins/cf_joomla_registrations.php around line 430):
        if ( $params->get('autologin') ) {
            $credentials = array();
            $credentials['username'] = $post['username'];
            $credentials['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string', JREQUEST_ALLOWRAW);
            $mainframe->login($credentials);
        }

Change that into this:

        if ( $params->get('autologin') ) {
            $credentials = array();
            $credentials['username'] = $post['username'];
            $credentials['password'] = $post['password'];
            $mainframe->login($credentials);
        }


/Fredrik
MSOlhao 29 May, 2010
Thanks for the code, but still not working.😑

Edit:

I got it working, instead of:
$credentials['password'] = $post['password'];

I changed it to:
$credentials['password'] = $post['password2'];


Now i have one more question, how can i email the generated password to the user🤨
nml375 30 May, 2010
Ahh, my bad;
Tested this, and it seems to work ok.

        if ( $params->get('autologin') ) {
            $credentials = array();
            $credentials['username'] = $post['username'];
            $credentials['password'] = $post['password2'];
            $mainframe->login($credentials);
        }


/Fredrik
MSOlhao 30 May, 2010
Yes, that's what i did, i have changed password with password2.
Did you read my other question?

In case not:
How do i email the generated password to the user🤨
nml375 30 May, 2010
Oh, must have overlooked that question.

The email should be included in the standard Joomla user email, though there seems to be the same issue of using JRequest::getString() here aswell. Around line 402, you'll find something like this:
        $password = JRequest::getString($params->get('pass'), '', 'post');

Change that to:
        $password = $post['password2'];


Hopefully, that should do the trick..

I'm not sure if this will work with any custom user emails though...

/Fredrik
MSOlhao 30 May, 2010
Hurray!!! 😀
That did the trick, thanks for your time.
jhdesign 16 Jul, 2010
I followed above message but I still do not get password sent, instead I get this:

You may now log in to http://www.mywebsite.com/ using the username and password you registered with.

Any ideas?
nml375 16 Nov, 2010
Hi jhdesign,
Seems I lost track of this thread for a while.

To the issue though, if you did not setup your Joomla system to require User Activation, then the Joomla email template will not contain any activation link, username, or password. Enabling User Activation however blocks the auto-login (can't login until you've activated your account).

There is, however, an option to use a custom email template (uses one of the form's emails). This won't work out of the box, though.. You'll need to add support for a {user} and {pass} macro.
Locate these lines (around line 413):
$MyFormEmails->emails[$emailid - 1]->enabled = 1;
$MyFormEmails->emails[$emailid - 1]->template = str_replace("{vlink}", JURI::base()."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $MyFormEmails->emails[$emailid - 1]->template;
$Myemail = array($MyFormEmails->emails[$emailid - 1]);

Extend it like this:
$MyFormEmails->emails[$emailid - 1]->enabled = 1;
$MyFormEmails->emails[$emailid - 1]->template = str_replace("{vlink}", JURI::base()."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $MyFormEmails->emails[$emailid - 1]->template;

$MyFormEmails->emails[$emailid - 1]->template = str_replace("{user}", $post['username'], $MyFormEmails->emails[$emailid - 1]->template);
$MyFormEmails->emails[$emailid - 1]->template = str_replace("{pass}", $post['password2'], $MyFormEmails->emails[$emailid - 1]->template);

$Myemail = array($MyFormEmails->emails[$emailid - 1]);


Also make sure you add your {user} and {pass} macros to your email template..

/Fredrik

Edit:
Fixed two typos that managed to sneak into the code while writing the post..
GreyHead 26 Nov, 2010
Hi,

Please see this post for a fixed version of the plug-in.

Bob
This topic is locked and no more replies can be posted.