Skip to Content Skip to Menu

Assign username on registration last name first initial

  • itsjeff
  • itsjeff
  • OFFLINE
  • Posts: 37
  • Thanks: 2
  • Karma: 0
7 years 7 months ago #286919 by itsjeff
Hello, I have found a few similar questions but need further guidance to get a solution working. Similar to this, but not using CB Connect www.joomlapolis.com/forum/255-developer-members-support/234372-set-username-on-registration-as-firstname-user-id

I am building a site with CB & CB Subs where users will register and be assigned a username. Their username will be their last name, first initial, and if that exists, add a number (beginning with 2). For instance:

John Smith = smithj
James Smith = smithj2
Joseph Smith = smithj3

I am not sure how to get just the first letter of first name, and how to add the incremented number. I would love to show the generated username on the registration page to the user, but less important as long as they get the login.

Please advise. Thank you!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68605
  • Thanks: 9108
  • Karma: 1434
7 years 7 months ago - 7 years 7 months ago #286934 by krileon
Only way to do that is with CB Auto Actions acting on the after registration trigger with a Code action that modifies the username. Alternatively you can try doing it with a database query in a Query action. Both should allow you to detect existing username and increment as needed, but both will require you to code these usages.


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.
Last edit: 7 years 7 months ago by krileon.
The following user(s) said Thank You: itsjeff

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

  • itsjeff
  • itsjeff
  • OFFLINE
  • Posts: 37
  • Thanks: 2
  • Karma: 0
7 years 7 months ago #286941 by itsjeff
Thanks for the response. It doesn't sound too hard to set up an auto action, but I'm not sure how to just get the first letter from the first name.

I'll do some reading up on the plugin's general usage but if you're able to advise on this particular part (or the use case) I would also appreciate that.

Thanks again,
Jeff

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68605
  • Thanks: 9108
  • Karma: 1434
7 years 7 months ago #286942 by krileon
CB Auto Actions comes with format functions, which you can enable under the parameters tab. One of them will let you grab the first letter of the firstname using the below for example.

[cb:parse function="extract" length="1"][firstname][/cb:parse]


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

Facebook Twitter LinkedIn