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 #302633 by wjgadmin
Replied by wjgadmin on topic User auto generated number
Thank you! 3 questions:
1. Unfortunately I cannot just place the 3 side by side because for some reason the [subscription_id] doesn’t work in the thank you email. In other words it is not available as a substitution string that I can see. Am I wrong?
Ironically I don’t see the plan_id nor the user_id in the available substitutions for the thank you email, but I believe in my testin they did work.

2. If I can use the code you provided, where would I place that code?

3. If (2.) worked, then I would be able to use the substitution string in the thank you email & post url params?
Last edit: 6 years 8 months ago by wjgadmin.

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 #302640 by wjgadmin
Replied by wjgadmin on topic User auto generated number
Presto! I was able to figure it out. Thank you very much for the example code!
Here is what I did, would you please confirm this is correct?

added the sample code into cbsubs/plan/integration/sql actions (SQL Action 1, Type = Internal, Activation = example code)
there is no need to place the code in the renewal/expiration/deactivation correct? since we already have it stored, i can simply provide that to my server via the url post using cb_license substitution?

if however i would like to place the code into the "Renewal", "Expiration" or "Deactivation" fields, would it produce a new license key or keep the same one it already has stored? i ask because we will have lots of members who already have accounts and do not have this license key generated on their accounts. so when they renew i would like to have it add this license key so it can send it to my server on their renewal (i would include cb_license field in the post).
so basically i am asking, is there a way to have it always generate a new key on activation & create a new one on renewal/expiration/deactivation ONLY IF there isn't already one stored?

again i cannot thank you enough, you've been very helpful! by the way, this did work for sending to my server & in the thank you email :)

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 - 6 years 8 months ago #302674 by wjgadmin
Replied by wjgadmin on topic User auto generated number
ok, here is what i've done. please confirm this is okay and logical.
i placed the code into the cbsubs plan/integrations/sql actions Activation, Renewal, Expiration and Deactivation as follows:
UPDATE `#__comprofiler` SET `cb_license` = MD5( '[user_id]_[plan_id]_[subscription_id]_SECRETKEY' ) WHERE `id` = '[user_id]'

i did this because there are lots of members who are already registered and they do not have this license key yet generated. so i need it to update/create one on each event. in my testing thus far it doesn't appear the license key ever changes even though the above command/code is being executed multiple times on the same user. is this because the key should never change, meaning it would always generate the same license key no matter how many times the code is run on it? i just want to make sure that it doesn't use any form of random generator in it because if the license key changes it will effect their license on our server.

lastly if the above is correct (see image), is there a way to generate the field value for all active subscribers of xxx plan. meaning i need to populate the license key for the members who are already active instead of waiting for a renewal, expiration or deactivation trigger to take place (run the sql code on these users).
thank you!
Attachments:
Last edit: 6 years 8 months ago by wjgadmin.

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 #302677 by krileon
Replied by krileon on topic User auto generated number
The query should only need to be done for Activation. You also need to of course replace SECRETKEY with an actual key only you know. MD5 is not random so no it's not going to change unless whatever you're encrypting changes.

i did this because there are lots of members who are already registered and they do not have this license key yet generated.

You should be able to just run a custom query directly on your database to handle this situation to get existing users their license keys. You'll need to create the query your self by updating _comprofiler with a subquery to _cbsubs_subscriptions since you need the subscription id and plan 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.

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 - 6 years 8 months ago #302696 by wjgadmin
Replied by wjgadmin on topic User auto generated number
when replacing the SECRETKEY, can that be any string of characters? meaning could i use all letters, or all numbers, or a combination of both? example something like this: TESTPASSWORD

You'll need to create the query your self by updating _comprofiler with a subquery to _cbsubs_subscriptions since you need the subscription id and plan id.

Kyle,
thank you sincerely for your help and support over the past few days. this is my last & final step to completion :)
i hate to ask, would you be so kind as to help me produce the sql query code to complete the update to all cbsubs of each specific subscription/plan? i know how to execute a query in phpmyadmin, however i am not sure how to create the correct code to do so. i could just run the code below, but as you mentioned i have to somehow run it on CB & CBSubs (i would like to do it for a specific plan instead of all subscriptions because some users have more than 1 subscription, don't know if that's possible?) and i am not familiar in that regards :( it would be most appreciated if you could provide me with the code to execute the sql query!

UPDATE `#__comprofiler` SET `cb_license` = MD5( '[user_id]_[plan_id]_[subscription_id]_TESTPASSWORD' ) WHERE `id` = '[user_id]'
Last edit: 6 years 8 months ago by wjgadmin.

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 #302700 by wjgadmin
Replied by wjgadmin on topic User auto generated number
I have tried to come up with the answer but not sure if i can get this one accomplished due to my complete lack of sql query knowledge. here is what i tried but still doesn't work, it provides an error:
UPDATE `sgj_comprofiler` SET `cb_license` = (FROM `sgj_cbsubs_subscriptions` MD5( '[user_id]_[plan_id]_[subscription_id]_TESTPASSWORD' ) WHERE `id` = '[user_id]')

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

Moderators: beatnantkrileon
Powered by Kunena Forum