[SOLVED] Automatic login after registration

9 years 7 months ago - 9 years 7 months ago #185909 by apessoa
Hello

I'm building a somewhat long registration process and want to break it in parts, so that users don't get scared of registering.

Rather than using the login tabs, I want the users to fill in the basic data and register and afterwards send them to a thank you page with a link/button to allow them to fill in the remaining data.
That way, even if they get scared and don't fill the remaining data, ate least are already registered and can be later invited to complete the missing fields.

My only issue is how to make them login automagically in that intermediate step, right after they register. I was thinking of using the AutoActions plugin, but have no ideia on the sintax to use.

Any help will be quite welcome.

Thanks in advance and best regards,
Alex

Please Log in to join the conversation.

9 years 7 months ago #185947 by krileon
Replied by krileon on topic Re: Automatic login after registration

My only issue is how to make them login automagically in that intermediate step, right after they register. I was thinking of using the AutoActions plugin, but have no ideia on the sintax to use.

This is very possible using CB Auto Actions. You'll need to set it up exactly as follows. Please note this will not work if you require admin approval or email confirmation.

Action 1 (must be first!)
Type: Code
Trigger: onAfterUserRegistration
User: Automatic
Access: Everybody
Condition: [block] Equal To 0
Method: PHP (use either of the 2 methods)
Code:
cbimport( 'cb.authentication' );

$cbAuthenticate		=	new CBAuthentication();

$messagesToUser		=	array();
$alertmessages		=	array();
$redirect_url		=	null;
$resultError		=	$cbAuthenticate->login( '[username]', false, 0, 1, $redirect_url, $messagesToUser, $alertmessages, 0 );
Return: Silent

Action 2 (must be after the above!)
Type: Redirect
Trigger: onAfterUserRegistration
User: Automatic
Access: Everybody
Condition: [block] Equal To 0
URL: index.php?option=com_comprofiler&task=userDetails

The above will provide auto login and redirect to profile edit. Please ensure you're using CB Auto Actions 2.1.0 for the above to properly work. Please note PHP execution is not allowed on some hosts so be sure to try both methods and if neither work you'd need to develop a custom integration to accomplish auto login.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: crony, valunite, pepperstreet

Please Log in to join the conversation.

9 years 7 months ago #186249 by apessoa
Replied by apessoa on topic Re: Automatic login after registration
Hi Krileon

Thanks for the help and updated plugin.

It works like a charm in localhost, hopefully will also work on the VPS, later on when I move the project.


I must say that I'm really impressed with the level of support: not only you've replied well within your SLA, but you also gave me a complete solution and an updated plugin.
That's not something we see everyday in other components development teams. :)
Thanks again :-) B)
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

7 years 4 months ago - 7 years 4 months ago #243374 by prestoproducts
Replied by prestoproducts on topic Re: Automatic login after registration
I have attempted this and have some errors showing up on it. Rather than listing the errors, I would rather explain the desired outcome as it is a slightly different case than above.
  • Email is used for login. Will the script still work if I change username to email?
  • Directly after registration form the user is sent to CB Subs invoice.
  • After a successful payment we are directing the user to a joomla welcome article.

By the time the user gets to the welcome article need them to be logged in. Currently they have to log back in after completing the payment and viewing thank you page. How can we set it to log the user at that time?

Lastly, can you double check the code that you pasted earlier? I am getting some syntax errors when I directly copy/paste.

Please Log in to join the conversation.

7 years 4 months ago - 7 years 4 months ago #243406 by krileon
Replied by krileon on topic Re: Automatic login after registration
You don't need this anymore. There's a Login/Logout action included with CB Auto Actions. Using it you only need to supply a login method and the value for it (e.g. Username method with [username] for Username). This will not behave well with CBSubs and it's not advised to interrupt the registration workflows when CBSubs is involved.

Please do not resurrect 2 year old topics as the information here is no longer relevant. Please always post a new topic in favor of resurrecting old ones and provide a link to the old one if you feel it is relevant. This keeps old information from being brought to the top, which can cause confusion.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.459 seconds

Facebook Twitter LinkedIn