[SOLVED] CBSubs to change username first time user subscrib

8 years 7 months ago #143996 by Ducatiklubben
Hello,

On our site we are using numbers as username for all active users. We have done this manually after the user is manually enabled in the back-end.

We have just installed CBSubs and planning to use it to control so that only paying users have access to forum etc.
My problem is that Joomla by default is setting username to "name + last-name". Now when we are automating the step to add the user to joomla we need some intelligence to set the usernamne to a number after the user has payed the subscription.

I have been reading this thread, which seems to have the same problem:
www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/id,95084/catid,90/limit,6/limitstart,12/

Anyone have ideas how to solve this? I need some help here
thanks

Post edited by: krileon, at: 2010/11/26 15:14
8 years 7 months ago #144038 by krileon
Yes this can be done using CBSubs SQL Actions, you'll need a complex query to check against the usernames and generate a sequential one or a random one that isn't already used. Example as follows.

INCREMENTAL
[code:1]
UPDATE `#__users` SET `username` = ( ( SELECT `username` FROM `#__users` WHERE `username` >= 1 ORDER BY `username` DESC LIMIT 1 ) + 1 ) WHERE `id` = [user_id]
[/code:1]

RANDOM
[code:1]
UPDATE `#__users` SET `username` = SUBSTRING( RAND(), 3, 6 ) WHERE `id` = [user_id]
[/code:1]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
8 years 7 months ago #144154 by Ducatiklubben
Hello Krileon,

Thanks for the code.
I have installed and tried it out and it seems to be executing ok. I don't get any error message when a user gets activatet, BUT nothing happens to the username.
The username for the new user is still "name + lastname" :(

Can I enable some error logging to be able to see what is happening?

Post edited by: Ducatiklubben, at: 2010/10/15 22:16
8 years 7 months ago #144233 by krileon

Can I enable some error logging to be able to see what is happening?

Not that I am aware.

Is the user subscribing to the plan you've added the query to? Have you ensured the CBSubs SQL Actions plugin is public and published?

You may want to review documentation subscriber incubator project CB Queries which can execute (internal and external) database queries at various locations via CB triggers such as After Registration. This would cause the query to apply to ALL users after the register (if that's what you want). More on incubator can be found here .

It's possible the query is happening and CB is storing AFTER the query causing the first + last to override the new username.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
8 years 7 months ago #144379 by Ducatiklubben
krileon wrote:

Is the user subscribing to the plan you've added the query to? Have you ensured the CBSubs SQL Actions plugin is public and published?


Yes, and the plugin is both public and published.

You may want to review documentation subscriber incubator project CB Queries which can execute (internal and external) database queries at various locations via CB triggers such as After Registration. This would cause the query to apply to ALL users after the register (if that's what you want). More on incubator can be found here .


Have I understand it correctly if I can configure so that I can use triggers to execute the SQL after the first registration has happened?

What I'm trying to accomplish is that when the user registers the first time and have done the payment, the user name changes to the number. This number shall never be changed in the future, even if the subscription expires. we never deletes a user or re-use the member number, just blocks the user to enter the site.
8 years 7 months ago #144421 by krileon

Have I understand it correctly if I can configure so that I can use triggers to execute the SQL after the first registration has happened?

There's only 1 registration, but yes you can configure it to execute a query/queries after registration.

What I'm trying to accomplish is that when the user registers the first time and have done the payment, the user name changes to the number. This number shall never be changed in the future, even if the subscription expires. we never deletes a user or re-use the member number, just blocks the user to enter the site.

Then using CBSubs SQL Actions isn't the best approach as everytime they resubscribe/renew it will re-execute that query.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
Moderators: beatnantkrileon
Time to create page: 0.388 seconds
Facebook Twitter Google LinkedIn