Skip to Content Skip to Menu

šŸŒ² Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with codeĀ XMAS-2024!

CB URL and Subscribers User access level settings

1 year 3 months ago #335081 by Ducatiklubben
Replied by Ducatiklubben on topic CB URL and Subscribers User access level settings
The PHP-script calls the procedure and generates a member number if the member hasn't been a member before. The procedure looks like this:

BEGIN declare user_name varchar(64); SET user_name = (select username from table_users where id = user_id); if user_name REGEXP '^-?[0-9]+$' = 0 then UPDATE table_users as a INNER JOIN ( SELECT * FROM table_users WHERE username>1 ORDER BY username DESC LIMIT 1 ) AS b on a.id = user_id AND b.username>1 SET a.username = b.username + 1; END IF; END

I think this was proposed by Joomlapolis back in 2010:Ā  www.joomlapolis.com/forum/92-news-discussions/143996-solved-cbsubs-to-change-username-first-time-user-subscrib?start=0 Ā 

Is it possible to do this is another way today?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 3 months ago - 1 year 3 months ago #335090 by krileon
Do the usernames need to be incremented or can they just be random? If random is ok then we've long since implemented support for random username fallback, which you can set in CB > Configuration > User Profile with the "Username Fallback" parameter then you'd just configure the username field to not be profile or registration.

Regardless yes there's a better way of dealing with this. It should be done at time of registration instead of left to CBSubs at time of subscription. For custom behaviors you'd use CB Auto Actions.


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: 1 year 3 months ago by krileon.

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

1 year 3 months ago #335106 by Ducatiklubben
Replied by Ducatiklubben on topic CB URL and Subscribers User access level settings
Yes, the username needs to be incremental. The club was started in1983 and the username then started from 1 and is now at 8874. Can you give us some help of how to set ut CB Auto Actions to set theĀ username (if the username is numeric it should not be changed).

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 3 months ago #335110 by krileon
I suggest moving this to CB Auto Actions then. The below is an example based off your procedure.

Global
Triggers: onAfterUserRegistration, onAfterNewUser
Type: Query
User: Automatic
Access: Everybody
Condition
Field: Username
Operator: Is REGEX
Value: /^-?[0-9]+$/
Action
Query:
Code:
UPDATE `#__users` as a INNER JOIN ( SELECT * FROM `#__users` WHERE `username` > 1 ORDER BY `username` DESC LIMIT 1 ) AS b ON a.`id` = '[user_id]' AND b.`username` > 1 SET a.`username` = b.`username` + 1;


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.

1 year 3 months ago #335120 by Ducatiklubben
Replied by Ducatiklubben on topic CB URL and Subscribers User access level settings
Thanks! As some username are none numeric it looks like the stored procedure is needed. I got everything to work with this:

Global
Triggers: onAfterUserRegistration, onAfterNewUser
Type: Code
User: Automatic
Access: Everybody
Condition
Field: Username
Operator: Is Not REGEX
Value: /^-?[0-9]+$/
Action
Javascript (URL)
URL: url to PHP-script calling the procedure

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

1 year 3 months ago #335122 by Ducatiklubben
Replied by Ducatiklubben on topic CB URL and Subscribers User access level settings
Hi again!

What trigger should we use to run this after payment is done successfully?

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

Moderators: beatnantkrileon
Powered by Kunena Forum