Ugly Data Move (adding to user groups)

Dan Allen

Active member
Will this work?

I don't really want to do this, but I am going to have to do it if it will work. I have 922 accounts I need to add to a new user group. Then after that, we are putting access to this group on sale to anyone who wants to cough up the dough ($77). We have money collection under control, but now I have to get new members into this user group basically instantly, right when they pay. So here is my plan.

DATA FOR ADDING A MEMBER TO A USER GROUP

  1. Add a record to the xf_user_group_relation table.
  2. On the xf_user record, add the user_group_id to the other secondary user groups the member has already. For example, what if they have 352c3234 that is hex for '5,24' and the new group is 37? I am thinking I'll change that to 352C32342C3337 which the heximadecimal for '5,24,37'
  3. Put an entry in the table xf_user_change log showing the old and new values
At that point, I am hoping it will be just like they were added through the admin screens
 
Last edited:
Or even use the User Upgrade system to take the payment which will automatically promote the users.
 
Why don't you use the Batch Update Users function in the ACP?
I can't figure out the criteria for selecting the 922 people from the other 3,000 users. Maybe there is a smart trick for doing that, like umm. Of the 922 users that need go into this new group, several hundred of them already are members. I am not seeing any fields in the user search that provide a way to select those folks, but I am taking another look.
 
I have a feeling there is a trick for selecting people for things like this that I haven't figured out or found out about yet. Believe me, I looked at at the batch update process, but I gave up after concluding there is not a way to select the people. There is no data in XF that would distinguish the 922 from others.
 
If there is no common and unique criteria then you won't be able to use the batch update function.

I wouldn't recommend editing the database manually as you have proposed though - use the UI.
 
Or even use the User Upgrade system to take the payment which will automatically promote the users.

Well, I did not know that XF has a user upgrade system that accepts payments. I am going to look at that now.

In the meantime, I am going to show you the answer, why we were not thinking of XF for payment processing.

This shows what we are working with and why we did not look toward Xenforo for payment processing. Basically, we have payment processing integrated and tailor made for our product development and sales processes.
upload_2016-4-7_14-19-9.webp

Each of the writing courses has a sales page explaining it. If someone wants to buy, they click a button and get this screen for selecting courses to buy. When they pay through stripe or paypal, we get notified of payment and we activate them in their course and the forum. Right now we have a lot of forums open to all members, because we don't know how to add them to specific forums automatically, based on which product they bought.

upload_2016-4-7_14-4-47.webp

I have been wondering if we should implement those subsystems using Xenforo or Zend framework as our platform. The big plus of our proprietary platform is our familiarity with it. However, we know Xenforo is superior software in its basic architecture and the details of how it is put together. I am a little leery of the database. We are not making software fo global consumption so there might be complexity inherent to Xenforo that is not appropriate for us.
 

Attachments

  • upload_2016-4-7_14-4-7.webp
    upload_2016-4-7_14-4-7.webp
    40.5 KB · Views: 1
Last edited:
Even if we made a decsion today to implement payment processing on XF as fast as possible, we stll would need to add those 922 members to a new user group. I am still hoping to find out if the data manipulations I mentioned are a complete spec for the data involved.
 
Even if we made a decsion today to implement payment processing on XF as fast as possible, we stll would need to add those 922 members to a new user group. I am still hoping to find out if the data manipulations I mentioned are a complete spec for the data involved.
I'm following along on this. I'm the site owner and creator of the courses.
 
I am still hoping to find out if the data manipulations I mentioned are a complete spec for the data involved.
No, and it's not something we would recommend, nor be able to support in the event of any issues.
 
Even if we made a decsion today to implement payment processing on XF as fast as possible, we stll would need to add those 922 members to a new user group. I am still hoping to find out if the data manipulations I mentioned are a complete spec for the data involved.
What format do you have these 922 users in? Do you have their user IDs or usernames or email addresses or all of the above?

(Brogan is certainly correct, but I'm just thinking if there's a "safer" way, but even then we wouldn't really recommend it and it would be at your own risk ;))
 
What format do you have these 922 users in? Do you have their user IDs or usernames or email addresses or all of the above?
First a correction. The 922 was only 461, because the 922 had two records per person.

Of the 461, 451 registered are xf members. We know who the 451, from records made by our previous membership system. We have a list of their xf_user_ID numbers. For every one of our classes, we have a list of the xf_userids for the people who are in the class. Selecting their xf_user_id in MySQL is pretty easy. I understand you cannot support our system if we do that.

Can we do this by building an addon?

Related: each of our writing courses has a private forum,with one user group that has access. When someone buys a class from our system outside xenforo, we have to add them to the right user group. How is that done?
 
I've moved this to dev discussions now because it seems to be going more in that direction.

If you have a list of user IDs this is probably ideal.

You can pass a load of user IDs directly into the batch update system. This would involve creating a custom page in the Admin CP that calls a template that looks something like this:

HTML:
<form action="{xen:adminlink 'users/batch-update'}" method="post">
    <input type="hidden" name="user_ids[]" value="1" />
    <input type="hidden" name="user_ids[]" value="2" />
    <input type="hidden" name="user_ids[]" value="3" />

    <button type="submit">Submit</button>
</form>

There are obviously multiple ways of doing this, but generating a template like the above in the Admin CP is probably quite straight forward. Obviously you would need the hidden inputs to be dynamically created, one for each of the user IDs you wish to update (the value of each input is the user ID).

Once you click submit, you should be taken to a page that looks something like this...

upload_2016-4-8_12-3-54.webp

Set your secondary group and click Update Users and after a minute or so, they should all be in the new user group.

Related: each of our writing courses has a private forum,with one user group that has access. When someone buys a class from our system outside xenforo, we have to add them to the right user group. How is that done?
I would probably look at creating a system that, again, utilises the User Upgrade system.

There's a method in the UserUpgrade model which when you pass in a user ID and a user upgrade record, it will take care of upgrading that user and promoting them to the relevant user group.
 
This design and code you laid out to is fabulous, I appreciate it a lot. I see how feeding the ids to the batch update will work.

Unfortunately, I still have some basics to learn about working in this system. I am hoping this tutorial will help. I know it will be tangent from the objectives I have at hand but it seems like this is the best way I could find to learn the basics i will need to apply what you told me.

I found another thread discussing basics of routing and the object use, I had no idea what that all meant.
 
Back
Top Bottom