XF 1.1 Query to add a member to a Donator usergroup

  • Thread starter Thread starter account8226
  • Start date Start date
A

account8226

Guest
Hello, I am using Paypal's IPN.

I would like that when a user donate correctly, it move him to my donator usergroup.

Actually I am using this :
PHP:
UPDATE  `xf_user`  
SET  `user_group_id` =  '9', `secondary_group_ids` = '2'
WHERE  `xf_user`.`user_id` ='".$id_user."';

My donator usergroup is 9, my member usergroup is 2. I still need to add my member to the 2 usergroup for permissions reasons.

When I'm doing this query, it move the user to this group, BUT without any permission.

Could anyone help me to fix this problem ? Or maybe you have a pre-made addon that is doing this ?

Thanks you very much.
 
You can't add members to user groups like that as the permission values won't update correctly.

The only way to add members to user groups is via the ACP or using an add-on which uses the datawriter.
 
You can't add members to user groups like that as the permission values won't update correctly.

The only way to add members to user groups is via the ACP or using an add-on which uses the datawriter.

Got it thanks Brogan, and is it easy to use datawriter ? Where is it ? And is there a tutorial ?

Regards.
 


Oh I have an idea.

1. I can create a custom profile field that the members can't edit themselves.
2. I create a usergroup promotion that would set the member to my donator usergroup ONLY if the custom profile field I created is "XXX" for example.
3. When the user make a donation, it use a query that add that "XXX" in the custom profile field.

Please Brogan, need your help, is my theory good ?

I investigated this solution for another person a few months ago. The theory is good but it is subject to cached values which must be rebuilt, just like other solutions. This rebuilds the user cache:

Admin CP -> Tools -> Rebuild Caches -> Rebuild User Caches

If you change the group in the user record then the cache must be rebuilt to update the permissions. If you set a custom field with a query then the cache must be rebuilt to update the field cache so the promotion will run. Either way you have to rebuild the cache.

With that said... the user upgrade system allows you to specify secondary groups to be added when a user pays. You can just use that. It uses secondary groups instead of the primary group like you want, but there is no functional difference between the two. This doesn't require any queries or complex promotion schemes. It is all within the user upgrade system.
 
With that said... the user upgrade system allows you to specify secondary groups to be added when a user pays. You can just use that. It uses secondary groups instead of the primary group like you want, but there is no functional difference between the two. This doesn't require any queries or complex promotion schemes. It is all within the user upgrade system.

Hey, thanks for te awnser, I don't really get that part, how can I add to a secondary usergroup when a user pays ?

Regards.
 
Top Bottom