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.

Comments

chertzog’s picture

StatusFileSize
new5.91 KB

Wow, that was embarrasing.... Here is the actual patch... forgot to add the new files.

criznach’s picture

I'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.

criznach’s picture

StatusFileSize
new2.3 KB

The 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.

chertzog’s picture

Like 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.

criznach’s picture

I'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.

paranojik’s picture

Title: New Sub Module » Track registration code uses
Issue summary: View changes
Status: Active » Needs work

Works fine. Would be nice to have a default view, though...

jphelan’s picture

I 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:

{ "rules_record_regcode_used" : {
    "LABEL" : "Record regcode used",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "regcode" ],
    "ON" : { "regcode_used" : [] },
    "DO" : [
      { "data_set" : { "data" : [ "user:field-reg-code" ], "value" : "[regcode:code]" } }
    ]
  }
}
ashrafen’s picture

StatusFileSize
new5.62 KB

I 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).

ashrafen’s picture

StatusFileSize
new5.62 KB

just a small change that wasn't applied to the previous patch (field tape in new table)

sumit@skytesters.com’s picture

I 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

sumit@skytesters.com’s picture

StatusFileSize
new5.8 KB

Please 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.