Taking Username Out Of Equation

11 years 11 months ago #202905 by krileon
Replied by krileon on topic Re: Taking Username Out Of Equation

By the way, where can I find documentation for Auto Action plugin?

There isn't any unfortunately, but an example can be found in the below tutorial.

www.joomlapolis.com/support/tutorials/107-use-cases/18237-assigning-usergroup-based-on-cb-field-value

An example of what you're wanting can be done with the below.

Type: Query
Triggers: onAfterUserRegistration
User: Automatic
Access: Everybody
Query:
UPDATE `#__users` SET `username` = MD5( `email` ) WHERE `id` = '[user_id]'
Mode: Internal

The above will change their username to an MD5 of their email address.

@ducks_mrd all of that can be down without a single core edit. Whether you use CB Auto Actions or you develop a new plugin to do specifically that. There is just no need for core edits and you risk breaking your entire site doing so as well as preventing us from helping you if you are to run into an issue (even if issue is unrelated, we do not help with core edits in place). First disable username, it then will use Name, then with after registration change it to whatever you want with a Field or Query action. If this is done then no validation issues will happen as username changes from name directly after registration so no two usernames would be alike. For example using a Field action you can set username to [email] to change it to username.


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.

11 years 11 months ago #202960 by timurdavidov
Replied by timurdavidov on topic Re: Taking Username Out Of Equation
Thanks, Kyle. That looks easy to accomplish.

However, I have to abandon the idea of username-to-email conversion due to potential security vulnerabilities, since users' profile URLs will now include their email address.

Would converting a username into an incremental numeric or alphanumeric ID be as easy as this one? It doesn't have to add the user's name to it, just the numbers and maybe letters. Could you please provide an example?

Thanks a lot!

Please Log in to join the conversation.

11 years 11 months ago #202970 by krileon
Replied by krileon on topic Re: Taking Username Out Of Equation

Would converting a username into an incremental numeric or alphanumeric ID be as easy as this one?

Yes, just replace email in the MD5 with username. You can also use RAND() to generate a random number instead if you wanted.


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.

11 years 11 months ago #202975 by timurdavidov
Replied by timurdavidov on topic Re: Taking Username Out Of Equation
Kyle, will RAND() generate a unique random number?

If yes, could you please give the actual code? Many thanks.

Please Log in to join the conversation.

11 years 11 months ago #202977 by krileon
Replied by krileon on topic Re: Taking Username Out Of Equation

Kyle, will RAND() generate a unique random number?

Yes.

If yes, could you please give the actual code? Many thanks.

Example is already given, just replace the MD5( `email` ) with RAND().


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.

11 years 10 months ago #202990 by ducks_mrd
Replied by ducks_mrd on topic Re: Taking Username Out Of Equation
Hi Kyle,

Thanks for that, my issues of the validation running and the javascript popup showing before the registration was completed is due to the fact that I am using this on an live site with users already in the database.

So I was hitting the issue that the validation was kicking in showing the javascript popup and not completing the registration so no auto action is being triggered.

Not a great way but to solve this in my case and eliminate any issues in the future, I am going to have run an update against all my current users and amend their records, to get rid of the username field using their name.



Sorry timurdavidov and Kyle for trying to solve the question with changing the code I was seeing the issue from my side with user records already being entered. On a new site Auto actions will just work and everything will be fine.

In future I will remember that a lot of readers on here are new to CB and using fresh installs with possibly just an admin in the database, unlike what I am doing.
As it does make a difference to the way CB reacts.

Apologies again for any confusion I caused.

Mike

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.227 seconds

Facebook Twitter LinkedIn