Assign Joomla Group based on Specific Login Module

9 years 1 month ago #260693 by kevinburk
I have two questions related to the CB login, and I've not been able to find any clear answers to them so far.

I'm creating a new site and will be installing CB 2 (I'm running 1.9 on my existing site, and these options aren't evident there).

I would like to be able to create a login form that allows users to create a new account and immediately assigns them to a pre-determined group (based on the specific page and log-in module they've accessed). I do not want users that create an account in any other manner to be assigned to the additional group.

To clarify: certain people will get a link to a hidden page, not accessible from anywhere else on the site. Users with this URL can set up an account and will automatically be added to the "Customer" group, which gives them additional access on the site.

I'd like to be able to automate this process so I don't have to manually upgrade each user when they register — but I also need people to be able to create a user account (which happens automatically with the shopping cart) but NOT be granted any special access if they create the account in this manner.

Is this possible?

Please Log in to join the conversation.

9 years 1 month ago #260764 by krileon
Out of the box, no. You'd need to a develop a plugin to do it or upgrade to Professional and use CB Auto Actions. Ideally you'd have have a Usergroup action that acts on the after registration trigger and conditions a URL get variable that you'd supply to the URL. So for example you'd add &customer=yes to the URL and in your action you'd have [get_customer] Equal To yes, which would then cause your action to perform its action (in this case give them a usergroup).


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.

9 years 1 day ago #262676 by kevinburk
Ok — I've upgraded and installed CB Auto Actions. And I have absolutely no idea how to accomplish what I need, so please walk me through this step-by step, as there doesn't seem to be any documentation at all for this plugin.

I will be creating a specific CB Login/Register module that will only be published on a specific page. This module needs to be different from the general registration module. [Module ID 123, if it matters]. Ive enabled the Plugins Integration for this module.

When someone registers using the new module, I would like them to be assigned to two groups:
Registered (default group, id 2) and PPNA [id 13].

I would also like to subscribe them to an additional ACYBA mailing list, but I'm guessing that will have to happen with a URL subscription since I don't want that list accessible with the standard log-in and it's a hidden list.

Is there a way to have the action add the group regardless of whether it's a new registration or an existing user logs in from the specific login module? Because many people will already have accounts.

Could you provide instructions as to how to do this?

Thanks so much.

Please Log in to join the conversation.

8 years 11 months ago #262721 by krileon
CB Auto Actions is a tool. There's nothing to document beyond what information is already provided by the input descriptions. It doesn't do anything without a usecase and won't document usecases beyond a few examples, because they're extremely specific to a persons needs. Below you can find some usecase examples.

www.joomlapolis.com/support/tutorials/107-use-cases
www.youtube.com/playlist?list=PLp0puRITgC7McQcw0Sli1qfSUQGwmflzi

The first issue is trying to determine what registration and login module the user just used. For the login module your only option is to create a template override for the login module. Next you need to add a hidden input to it. The value of that hidden input is what you'll be looking for in CB Auto Actions using a conditional. Example as follows.

[get_HIDDEN_INPUT_NAME] Equal To VALUE_HERE

Check Joomla documentation on how to use template overrides. You should be able to just copy either the default or bootstrap template from CB Login module and modify it to have the needed hidden input. Another option is to copy the template file, rename it, leave it in the modules template folder, and then add the hidden input. Next you'd select its template for your specific login module.

For registration it gets a bit tricky. You'd need to again modify the login module template and append a new variable to the end of the registration URL. You'd then grab that variable on the before registration form display trigger using a Code action with Method set to jQuery and add a hidden input to the form. Now you should be able to act on the after registration trigger and condition against the hidden input like done above.

I can't really make much sense of why you're doing this though. It has zero security to it. You've no way of knowing if they actually came from that module as it's just a GET variable that anyone could add to the URL. Is there not something more specific that you could condition off of during the registration or login process?


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.

8 years 11 months ago #262730 by kevinburk
I upgraded my subscription to get this plug-in based on your initial reply to my question because you indicated it would be simple for the Auto Actions plug-in to accomplish this task. Now you're telling me it's either not easy or not possible?

I'm not a coder. I need clear instructions about how to set up the Auto Actions to append a group when someone uses the registration module. There's a redirect page that I can specify in the module once someone has logged in. Why do I have to modify templates? Why can't I just append the code to that URL so when someone uses THAT log-in form to register or log in, it triggers the auto action and they're added to the new group?

I just don't know how to set up the action or what to append to the redirect URL in the form. That's what I expected to be able to do with the upgraded membership.

Security is not an issue. Only people with the hidden URL will ever access this registration page, and it's not like they're getting administrator access to the site. They're just getting access to some additional downloads.

Please Log in to join the conversation.

8 years 11 months ago #262739 by krileon

I upgraded my subscription to get this plug-in based on your initial reply to my question because you indicated it would be simple for the Auto Actions plug-in to accomplish this task. Now you're telling me it's either not easy or not possible?

It's possible it's just not simple.

Why do I have to modify templates? Why can't I just append the code to that URL so when someone uses THAT log-in form to register or log in, it triggers the auto action and they're added to the new group?

Because that's not how code works. The login form is client side. When it's submitted it's sent server side. You need a way of determining service side that the form they submitted is the one you want to give them a usergroup for. The way to do this is to send a variable with the form that you can check in CB Auto Actions. The below for example should allow for this after logging in with your specific module.

Triggers: onAfterLoginForm
Type: Code
User: Automatic
Access: Everybody
Conditions: [var4] Equal To MODULE_CLASS_SUFFIX_HERE
Method: jQuery
Code:
$( '.cbLoginForm' ).prepend( '<input type="hidden" name="special_login" value="1" />' );

The above will add the hidden input to the login form if its module class suffix matches. It'll apply it to all login forms on the page to ensure failed login attempts, login page, and multiple login displays would all function correctly.

Triggers: onAfterLogin
Type: Usergroup
User: Automatic
Access: Everybody
Conditions: [post_special_login] Equal To 1
Mode: Add Usergroups
Groups: SELECT_GROUPS_TO_ADD_HERE

The above will then check that the special login hidden input value is present in the POST since we added it to the login form it should be there. If it is we'll then add the usergroups as needed.

For the above to work you need to use the module class suffix parameter of CB Login module. It's the only way in the trigger we'll know that we're adding the hidden input to the correct module.

The above is an example of how to do this strictly with CB Auto Actions and without modifying any template files. Using a template override would be better, but if you've no experience with template overrides the above should be ok. Please note this is an example and I did not test it; we're not here to provide custom coding and we only provide limited examples.


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.215 seconds

Facebook Twitter LinkedIn