Announcement

Collapse
No announcement yet.

Group Memberships

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Group Memberships

    I need to make a change to a bunch of usergroups based on last activity. I can use prune/move users for primary usergroup but I also need to revert additional usergroups.

    Essentially here is what I want to do:
    1. Find users based on Primary Usergroup
    2. Further find users in that usergroup who have not logged in for 30 days.
    3. Where both criteria match, move to registered.
    4. Remove all additional usergroup permissions.
    Pretty much what I am doing is reverting all users who have not logged in for 30 days to normal registered users as if they just came to the forums. Is there any easy way to do this? Thanks in advance if anyone can help me.
    Last edited by Hamma; Mon 5th Mar '07, 7:36am.

  • #2
    This query should do it (backup first):

    Code:
    UPDATE user
    SET usergroupid = 2, membergroupids = ''
    WHERE usergroupid = X
    AND lastactivity < UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))
    Where X is the usergroupid of the current primary group.

    Comment


    • #3
      Sweet!

      Do I need to modify that in any way or does that do last 30 days?

      Comment


      • #4
        It only does users who are not active in the last 30 days. Of course you will want to backup and check the results afterwards.

        Comment


        • #5
          Aye - thanks in advance I will give it a shot in a few days

          Comment


          • #6
            One more question.. what if I wanted to modify that for the last 40 days?

            The deal is I am going to send a warning email to people who have not logged in for 30 days that they have 10 days to login otherwise be pruned.

            Comment


            • #7
              Code:
              UPDATE user
              SET usergroupid = 2, membergroupids = ''
              WHERE usergroupid = X
              AND lastactivity < UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 40 DAY))

              Comment

              Loading...
              Working...
              X