Alter Username using query?

6 years 4 months ago #299760 by sirweb
Alter Username using query? was created by sirweb
I would appreciate a little push forward... :)

How can I add a prefix to a Username depending on a field value?
Which plugin is best to use Auto Actions or CB Query?
I have a single select field cb_typ that can have values 1-7
If the value is 2,3,4 or 5, I want to add the value plus an underscore as prefix to the username, ex. '5_William Smith'

Please Log in to join the conversation.

6 years 4 months ago #299782 by krileon
Replied by krileon on topic Alter Username using query?
If it's just for display purposes I do not recommend altering the stored value. You can simply use the Profile Value Layout parameter under the Layout tab of the username field (or formatname field for usage outside of profile) to add a prefix. To add a prefix based off a field value simply use IF substitutions. See the below substitution tutorial for IF substitution usage information.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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 4 months ago #299806 by sirweb
Replied by sirweb on topic Alter Username using query?
Actually, it is not for display purposes.
I really want to alter the stored username.

We do never delete user account, we store them for statistical and historical reasons.
But users don´t have access to their accounts any longer.
Best solution had been to move obsolete account to an other DB, but I haven´t found a solution like that.

Please Log in to join the conversation.

6 years 4 months ago #299817 by krileon
Replied by krileon on topic Alter Username using query?
Ok, in that case you can use CB Auto Actions on the after user registration and after user update triggers. You'd need to condition for your fields then you can use a Field action to alter the username (it has a prefix operator).


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.
The following user(s) said Thank You: sirweb

Please Log in to join the conversation.

6 years 4 months ago #300119 by sirweb
Replied by sirweb on topic Alter Username using query?
Thanksm sounds promising. :)

I guess onAfterUpdateUser would be enough as it is all about disabling alreadt registered users.

Does onAfterUpdateUser react on both frontend and backend updates.
Does it react on CBjuice2 CSV import as well?

Thanks

Please Log in to join the conversation.

6 years 4 months ago #300140 by krileon
Replied by krileon on topic Alter Username using query?

I guess onAfterUpdateUser would be enough as it is all about disabling alreadt registered users.

Yes, but please also keep the below in mind as you may need this to work in both frontend and backend depending on where you're editing users.

onAfterUserUpdate = Frontend
onAfterUpdateUser = Backend

Does it react on CBjuice2 CSV import as well?

I've no idea. That'd depend entirely on if CB Juice 2 fires triggers or not.


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

Facebook Twitter LinkedIn