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

Expired account upgrades

Discussion in 'Troubleshooting and Problems' started by Blue, Sep 18, 2011.

  1. Blue

    Blue Well-Known Member

    I have an account upgrade where the user can have a custom title and a sig. I noticed an account that the upgrade had expired and the custom title reverted but the account still was showing a sig in the postbit. Is this normal? I thought that once the secondary usergroup was removed all the secondary permissions would be removed as well.
     
  2. ragtek

    ragtek Guest

    The permissions are only checked, while you save the new signature.
    So you would need an cronjob or extend the userupgrade cron to check and remove the signatures or you could send a conversation that the user needs to change the signature ...
     
  3. Blue

    Blue Well-Known Member

    I believe a cronjob would be the best solution, but I have no idea how to do it. If there is a query I could run that would only clear sigs for those that did not have the secondary usergroup that might work too.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I like queries.

    Code:
    UPDATE xf_user_profile AS user_profile
    SET user_profile.signature = ''
    WHERE (
    	SELECT user.user_id
    	FROM xf_user AS user
    	WHERE user.user_id = user_profile.user_id
    	AND NOT FIND_IN_SET(23, user.secondary_group_ids)
    );
    
    Change the red piece to specify the group id that grants signature permissions.

    Backup first. And please understand that this clears signatures for all users who do not belong to the specified group. For example, if an admin is not also in that group then their signature will get cleared. You may wish to exclude admins and mods, like this:

    Code:
    UPDATE xf_user_profile AS user_profile
    SET user_profile.signature = ''
    WHERE (
    	SELECT user.user_id
    	FROM xf_user AS user
    	WHERE user.user_id = user_profile.user_id
    	AND NOT FIND_IN_SET(23, user.secondary_group_ids)
    	AND NOT FIND_IN_SET(3, user.secondary_group_ids)
    	AND NOT FIND_IN_SET(4, user.secondary_group_ids)
    );
    
    Basically you are specifying all secondary groups that are allowed to have signatures.
     
    Blue likes this.
  5. MGSteve

    MGSteve Well-Known Member

    Is there anyway this could be built into the XF core as I need a similar feature due to the fact we give extra features to those who subscribe, which then need to be removed should their subscription lapse.

    I'd have thought anyone who did similar (probably most people who use account upgrades) will need this.
     
    GeeksChat likes this.
  6. Blue

    Blue Well-Known Member

    This should do the job just fine. I have to wait until the 21st to run it, that's when the next user with a sigs upgrade expires.

    Thanks Jake.
     
  7. Blue

    Blue Well-Known Member

    I would like to see it built in as well.
     
  8. Blue

    Blue Well-Known Member

    Custom titles are not reverting after an upgrade expires in some cases. Is there a query I could run similar to this one to revert custom titles after an upgrade expires?




     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Try this:

    Admin CP -> Tools -> Rebuild Caches -> Rebuild User Caches
     
    Blue likes this.
  10. Blue

    Blue Well-Known Member

    Thanks Jake :)
     
  11. Blue

    Blue Well-Known Member

    Hey Jake, this doesn't seem to be working. Do you know of a query like this one that would clear custom titles?

    Code:
    UPDATE xf_user_profile AS user_profile
    SET user_profile.signature = ''
    WHERE (
        SELECT user.user_id
        FROM xf_user AS user
        WHERE user.user_id = user_profile.user_id
        AND NOT FIND_IN_SET(23, user.secondary_group_ids)
        AND NOT FIND_IN_SET(3, user.secondary_group_ids)
        AND NOT FIND_IN_SET(4, user.secondary_group_ids)
    );
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  13. Blue

    Blue Well-Known Member


    I don't want to clear all of them I need to keep them for 2 usergroups. Something like this.


    UPDATE xf_user
    SET custom_title = '';
    WHERE (
    SELECT user.user_id
    FROM xf_user AS user
    WHERE user.user_id = user_profile.user_id
    AND NOT FIND_IN_SET(3, user.secondary_group_ids)
    AND NOT FIND_IN_SET(4, user.secondary_group_ids)
    );
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    UPDATE xf_user
    SET custom_title = ''
    WHERE NOT FIND_IN_SET(3, secondary_group_ids)
    AND NOT FIND_IN_SET(4, secondary_group_ids);
    
     
    Blue likes this.
  15. Blue

    Blue Well-Known Member

    Great. Thank you.
     
  16. Blue

    Blue Well-Known Member


    Sorry I thought I was covered with just 2 usergroups but I need to exclude 3 different usergroups. I tried adding another line but it doesn't work and I get an error.
    Code:
    UPDATE xf_user
    SET custom_title = ''
    WHERE NOT FIND_IN_SET(3, secondary_group_ids)
    AND NOT FIND_IN_SET(4, secondary_group_ids)
    AND NOT FIND_IN_SET(5, secondary_group_ids);
    
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    @Blue

    What error?
     
  18. Blue

    Blue Well-Known Member

    I must have not taken my meds today. I just ran it again and it was fine. Sorry to bother you Jake.
     

Share This Page