Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Auto-generate numeric username

  • mev55
  • mev55
  • OFFLINE
  • Posts: 12
  • Thanks: 0
  • Karma: 0
13 years 6 months ago #165705 by mev55
Replied by mev55 on topic Re: Auto-generate numeric username
Can you please clarify this, because I don't see any setting to allow autogeneration of usernames.

Please Log in or Create an account to join the conversation.

  • ronsmart
  • ronsmart
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
13 years 6 months ago #166684 by ronsmart
Replied by ronsmart on topic Re: Auto-generate numeric username
Battra did this work for you? I am looking to do the same thing. If so can you explain?

Please Log in or Create an account to join the conversation.

  • ronsmart
  • ronsmart
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
13 years 6 months ago #166685 by ronsmart
Replied by ronsmart on topic Re: Auto-generate numeric username

beat wrote: Probably the CB Queries from incubator could be your solution here:

www.joomlapolis.com/cb-solutions/incubator

Execute fully customizable database queries when CB events happen. This tool can be used to provide rudimentary integration with other bridged scripts. You can even connect to external host databases!


Using the on after new user creation and on after registration events you could set jos_users-username = jos_users.id

And not show username at registration, so that cb auto-fills it based on email before your trigger sets it to id.

I didn't try above, but it might work, if your joomla version accepts such all-numeric usernames. Otherwise prefix in the query with an alphanumerical character.


I am stuck here - Using the on after new user creation and on after registration events you could set jos_users-username = jos_users.id. How would you query this?

Please Log in or Create an account to join the conversation.

  • ronsmart
  • ronsmart
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
13 years 6 months ago #166686 by ronsmart
Replied by ronsmart on topic Re: Auto-generate numeric username

ronsmart wrote:

beat wrote: Probably the CB Queries from incubator could be your solution here:

www.joomlapolis.com/cb-solutions/incubator

Execute fully customizable database queries when CB events happen. This tool can be used to provide rudimentary integration with other bridged scripts. You can even connect to external host databases!


Using the on after new user creation and on after registration events you could set jos_users-username = jos_users.id

And not show username at registration, so that cb auto-fills it based on email before your trigger sets it to id.

I didn't try above, but it might work, if your joomla version accepts such all-numeric usernames. Otherwise prefix in the query with an alphanumerical character.


I am stuck here - Using the on after new user creation and on after registration events you could set jos_users-username = jos_users.id. How would you query this?


Also jos users or cb users? I am using CB independently.

Please Log in or Create an account to join the conversation.

  • apdt
  • apdt
  • OFFLINE
  • Posts: 92
  • Thanks: 2
  • Karma: 3
13 years 6 months ago #166696 by apdt
Replied by apdt on topic Re: Auto-generate numeric username
Please read this thread as well, it contains details on how to auto-generate username (there's a bug where CB auto-generate username using first+lastname instead of email) so you can hide the username field.
--> www.joomlapolis.com/forum/88-usage/164680-username-is-assigned-first--last-instead-of-email#164891

What I did was:
1. Create new CB field 'cb_memberid' and create a dummy user so I can fill in the field with a number as the member username base (e.g. assign the dummy user member ID 100)
2. Install SQL Action integration plugin
3. I'm using CB Subs so for each plan, go to Integration tab > SQL Action and put this query in the Activation & Renewal field:
Code:
UPDATE jos_users SET username = (SELECT MAX(cb_memberid)+1 FROM jos_comprofiler) WHERE id = [user_id]; UPDATE jos_comprofiler SET cb_memberid = (SELECT username FROM jos_users WHERE id = [user_id]) WHERE user_id = [user_id];
Basically it sets the username to the next available number based on the cb_membership last/highest value.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
13 years 6 months ago #166697 by krileon
Replied by krileon on topic Re: Auto-generate numeric username
This is better done with CB Fields as it alters the user object and database row in a safe manner. Once installed use the on after registration trigger, set access to everybody, don't specify a condition (unless you want to). Then select the Username field to change. Now you can format the name however you like; substitutions are allowed. If you need complex formatting then yes you'll need to use CB Queries to change the username; example as follows.
Code:
UPDATE `#__users` SET `username` = CONCAT_WS( '_', '[firstname]', '[lastname]' ) WHERE `id` = [user_id]


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum