1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Query to add a member to a Donator usergroup

Discussion in 'XenForo Questions and Support' started by account8226, Feb 27, 2012.

  1. account8226

    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 :
    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.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    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.
  3. account8226

    account8226 Guest

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

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
  5. account8226

    account8226 Guest

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

  6. Brogan

    Brogan XenForo Moderator Staff Member

    Elly likes this.

Share This Page