Assign Joomla Group based on Specific Login Module

6 years 9 months ago #262748 by kevinburk
Thank you — I'm still a little confused by this though.

Do I copy the code exactly as is, or do I have to specify my own variables (e.g., [var4])?

This is two different actions in CB Actions?

For the Module Class Suffix — I don't have to create a specific style for it in the css do I? I can just come up with any name for it in the module? Does it need an underscore before it? Or can I just define a suffix PPNA?

Please Log in to join the conversation.

6 years 9 months ago #262749 by kevinburk
Thank you — this almost does what I need it to do.

If someone has already created an account, when they login through this form, it now adds them to the correct group. However, if someone creates an account from this module, it doesn't add them to the correct group.

What do I need to set as the trigger (and to which action) so that someone who completes the registration from this specific module is automatically added to the additional groups?

Please Log in to join the conversation.

6 years 9 months ago #262753 by krileon

Do I copy the code exactly as is, or do I have to specify my own variables (e.g., [var4])?

As is.

This is two different actions in CB Actions?

Yes.

For the Module Class Suffix — I don't have to create a specific style for it in the css do I? I can just come up with any name for it in the module? Does it need an underscore before it? Or can I just define a suffix PPNA?

No you don't need any CSS. It's just being used for the condition. It can be whatever you want. You just need to match it 1:1 in CB Auto Actions.

However, if someone creates an account from this module, it doesn't add them to the correct group.

That's because I didn't provide that scenario. The jQuery would need to be extended to add a parameter to the registration URL that you could pick up at registration to add the hidden input. Then you'd just check for the hidden input again.

What do I need to set as the trigger (and to which action) so that someone who completes the registration from this specific module is automatically added to the additional groups?

The below actions will probably work for both scenarios.

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="post_special_group" value="1" />' );
$( '.cbLoginForm #form-login-register > a' ).attr( 'href', $( '.cbLoginForm #form-login-register > a' ).attr( 'href' ) + '&special=1' );

Triggers: onBeforeRegisterFormDisplay
Type: Code
User: Automatic
Access: Everybody
Conditions: [get_special] Equal To 1
Method: jQuery
Code:
$( '.cbRegistration > form' ).prepend( '<input type="hidden" name="post_special_group" value="1" />' );

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

So in total you'd have 3 actions. Please note the above is untested and provided as an example. The idea is to modify the registration URL in the module and add &special=1 to it. Then on registration display we check that it exists in the URL and prepend the hidden input, which we'll pick up in the 3rd action.


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.

6 years 9 months ago #262756 by kevinburk
This doesn't work — when I go to the module page and try to create a new account, the url for the new registration page with the "special=1" gives an error code saying I have to log in or register to view my profile.

Please Log in to join the conversation.

6 years 9 months ago #262757 by kevinburk
Also: There's no trigger for AfterUserRegistration. There's a frontend user registration trigger.

Please Log in to join the conversation.

6 years 9 months ago #262763 by kevinburk
SIMPLE (HOPEFULLY) SOLUTION REQUEST

I think I've got a simple solution that will address all of my needs. The first set of code you gave me worked perfectly with the login form, but not with the registration form.

Since when you register, it doesn't also log you in, all I need is to have the CB Actions code so that I can set a custom URL redirect when someone successfully registers from this custom module. That way, they'll get taken back to the correct login page, and when they login, they'll get added to the appropriate groups.

I'm guessing that this is the first part of what I need to set up with the action:

Triggers: onAfterFrontendRegistration
Type: Code
User: Automatic
Access: Everybody
Conditions: [var4] Equal To MODULE_CLASS_SUFFIX_HERE
Method: jQuery

I just don't know what code to put in the jQuery box.

Thanks for your help with this.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.213 seconds

Facebook Twitter LinkedIn