Skip to Content Skip to Menu

[SOLVED] User auto generated number

  • wjgadmin
  • wjgadmin
  • OFFLINE
  • Posts: 489
  • Thanks: 28
  • Karma: 4
6 years 8 months ago - 6 years 8 months ago #302586 by wjgadmin
[SOLVED] User auto generated number was created by wjgadmin
Hi
I’ve recently gotten my CBSubs http post working and I’m trying to figure out a way to have community builder generate a very unique sequence of numbers and letters or it can just be numbers. Basically I need it to look like a serial key so I can pass it to our server to identify that specific user and allow them to activate their software using this key, which I will code our server to accept.
I tried passing their [subscription_id][plan_id] which would’ve worked but 2 problems:
1. It’s only available in the integration/url as a usable field substitution & I must have it available in the plan/presentation/thank you email so the user actually receives it on sign up.
2. It would’ve only been 6 characters long

Is there a way I can auto populate a random number sequence for each user upon registration that is unique to them alone & that can be used in the thank you email & passed in the integration/url post?
Basically it would be like adding another field that is hidden and auto populates in the backend & is useable as a substitution string?
Example: [user_license_key]

Thank you
Last edit: 6 years 8 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
6 years 8 months ago #302609 by krileon
Replied by krileon on topic User auto generated number
The only thing really unique per user is their user id, which you can substitute using [user_id]. You won't be able to generate a unique license id and store it using CBSubs alone. You'll likely need CB Auto Actions for that since you can use the Code action to execute whatever custom PHP you want after registration or after a user subscribes for example. CB Code field I suppose could be used to generate a license key dynamically as well I guess.

Your alternative is to send the user id, plan id, and subscription id in your HTTP post then generate your key in your external script and maybe that'd be of use in your custom script, but CB won't have any access to that.

Another alternative is to try and use entirely SQL to generate the license then use CBSubs SQL Actions to generate and store it to a field. This would avoid needing CB Auto Actions, but severally limits the encryption you can apply to the license (you don't want something that can be easily guessed; it should be hashed by something only you know).


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.

  • wjgadmin
  • wjgadmin
  • OFFLINE
  • Posts: 489
  • Thanks: 28
  • Karma: 4
6 years 8 months ago #302613 by wjgadmin
Replied by wjgadmin on topic User auto generated number
I like the idea of using the:
user id, plan id, and subscription id

I can easily submit that to my server however the issue is getting it to the user themselves. For example the subscription_id cannot be sent in the thank you email as a substitution string.
How can I send (user id, plan id, and subscription id) both in the integration/url post & the plan thank you email (this is what I’d like to do)? Note: if I can’t send it to them in the thank you email it doesn’t do any good because they wouldn’t know what the key is to use it. Thank you

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
6 years 8 months ago - 6 years 8 months ago #302615 by krileon
Replied by krileon on topic User auto generated number
Your license should ideally be an encrypted value of user id, plan id, and subscription id with a secret key only you know. Don't just place all 3 next to one another as that could be too easily predictable. To do this you really need access to PHP or at least SQL where you can try to generate an encrypted key. Since you need this in CB it self my guess is your only option is to generate it using CBSubs SQL Actions (using SQL) or CB Auto Actions (using PHP or SQL). You'd also generate it at your PHP endpoint, but since you know the secret key they should be identical (can be a simple MD5, which is at least better than plan text). See the below SQL documentation for encryption functions if you just want to use CBSubs SQL Actions to do this.

dev.mysql.com/doc/refman/5.6/en/encryption-functions.html

Example as follows.

Code:
UPDATE `#__comprofiler` SET `cb_license` = MD5( '[user_id]_[plan_id]_[subscription_id]_SECRETKEY' ) WHERE `id` = '[user_id]'

Just replicate the MD5 in your script if your script needs the license as well. The above for example would store this to the field cb_license which could just be a read only text field for example.


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: 6 years 8 months ago by krileon.

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

  • wjgadmin
  • wjgadmin
  • OFFLINE
  • Posts: 489
  • Thanks: 28
  • Karma: 4
6 years 8 months ago #302622 by wjgadmin
Replied by wjgadmin on topic User auto generated number
Thank you so much for this & I am going to read it over further & process it.
However I should explain, even if the license key is predictable it is ok. Our server is set up in a way to check multiple things & even if someone else were able to get the users license key they wouldn’t be able to use it anyway:-) It is actually being used as more of an identifier just like their name, email etc... would be. The one important thing however is that it is unique to that user & can get passed in both the url post & the thank you email.
Knowing this, is there a way to get that done?

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
6 years 8 months ago - 6 years 8 months ago #302626 by krileon
Replied by krileon on topic User auto generated number
Well my above example will store it to a field, but that may happen too late for it to be sent in the email. Worth a shot substituting in the [cb_license] field though I guess. Aside from that I don't know what to tell you beyond you'll need to code a custom CBSubs plugin your self to generate the license sooner or use CB Auto Actions to try and do that. If you're fine with it being plain text then I guess just place the 3 substitutions directly next to each other: [user_id][plan_id][subscription_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.
Last edit: 6 years 8 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum