There have been a number of posts about tracking the users who use a reg code.
#1014970: List of users by registration code
#1118390: Search who owns a code?
Here is a patch that adds a sub module "Registration Code Users."
What it does is add a column to the regcode table called 'creator.' In my use case, I was calling regcode_generate and regcode_save from a custom module to allow codes to be generated by a process after an ubercart transaction. I wanted to be able to see what user was "buying" the code. The first thing this patch does is add a new hook "hook_regcode_save" and adds it to the regcode_save function.
Then the new sub module, adds a table to track the regcode, the user who used the regcode, and the time it was used.
In addition, all of the information is described to views, and you can easily make a view to list who has used what code.
I would also be willing to offer co-maintainership of the regcode module.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | regcode_track_user_of_code.patch | 5.8 KB | sumit@skytesters.com |
| #9 | regcode_users.patch | 5.62 KB | ashrafen |
| #8 | regcode_users.patch | 5.62 KB | ashrafen |
| #3 | regcode_users.zip | 2.3 KB | criznach |
| #1 | regcode_users.patch | 5.91 KB | chertzog |
Comments
Comment #1
chertzogWow, that was embarrasing.... Here is the actual patch... forgot to add the new files.
Comment #2
criznach commentedI've just started looking at this, so I can't vouch for how well it works. But it's an important feature that I think should be committed.
Comment #3
criznach commentedThe patch appears to be working. For users who are reluctant to patch, or want a clean upgrade, you should be able to install the attached regcode_users module to your contrib modules folder and enable it. It doesn't need to be in the regcode folder, although that's where the patch puts it.
NOTE: The code creator field will never be populated because the core regcode.module needs to be patched. Other than that, it should work fine.
Comment #4
chertzogLike i mentioned in my original posting, I was populating the regcode creator field programmatically via a custom module. If this were to get committed we would probably want to remove that column, or make it populate with the admin who is actually creating the code.
I have been using this in production for over 7 months with no problems.
Comment #5
criznach commentedI've been testing it heavily all day with no problems. One thing that would be nice is the ability to delete the user association without writing queries, but I have been able to work around it.
Comment #6
paranojik commentedWorks fine. Would be nice to have a default view, though...
Comment #7
jphelan commentedI accomplished this by using rules and a custom field on the user. You do have to apply this patch to get rules working though:
https://www.drupal.org/node/1923224#comment-9122075
Example Rule:
Comment #8
ashrafen commentedI have found some issues with the previous patch that didn't give us the right tracking for the users and their used regcodes.
I'm submitting this new patch that fixes wrong relation between user and the rid (regcode).
Comment #9
ashrafen commentedjust a small change that wasn't applied to the previous patch (field tape in new table)
Comment #10
sumit@skytesters.com commentedI used the above patch seems like entry for rid ,which i thing is supposed to be registration code ID is auto incremental as per my observation looking at the database table. Shouldn't it be replaced with rid of registration code bieng used instead of auto increment
Comment #11
sumit@skytesters.com commentedPlease ignore the above comment,below is the fixed patch with drupal 7.43 version. where function regcode_users_regcode_used(&$code, &$account) was having three arguments out of which edit was not required and code is the first argument.