Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Documentation] Users have been Orphaned how do i auto add them all to a role?

H00jH00j
edited April 2012 in Vanilla 2.0 - 2.8

I have about 25 pages of users and several random ones have been orphaned is there away i can add them all to a group with out doing everypage manually

Best Answer

  • UnderDogUnderDog MVP
    edited April 2012 Answer ✓

    I have no solution, but a couple of MySQL selects to figure out more information:
    All users which do not have a Role in the UserRole table:

    select u.UserID
    from GDN_User u
    left join GDN_UserRole ur
    on u.UserID = ur.UserID
    where ur.UserID is null;
    

    All users with multiple Roles:

    select u.UserID
    from GDN_User u
    join GDN_UserRole ur
    on u.UserID = ur.UserID
    GROUP BY ur.RoleID
    ORDER BY ur.RoleID DESC;
    

    edit
    Also figure out exactly what you want to do with which type of users.

    For example : For every user that has role 33 I want him to give only role 8
    Every user that has role 27 will only get role 33
    etcetera etcetera

    There was an error rendering this rich post.

Answers

  • peregrineperegrine MVP
    edited April 2012

    Do you want to switch them all to one user.

    or do you want to change the role for a select number of users?

    what do you mean 25 pages?

    if you have access to phpmyadmin

    you could just place a check box next to each userid you want to change the role on on update to the new roleid you want. or you could use mysql.

    if you really are changing roles - look in UserRole table.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • ToddTodd Chief Product Officer Vanilla Staff

    You'll need to run a bit of SQL. Check out this discussion.

  • H00j said:
    I have about 25 pages of users and several random ones have been orphaned is there away i can add them all to a group with out doing everypage manually

    I agree with what my neighbours above me said and I have something to add. Figure out why you have 25 pages of users without a Role attached. Did you delete a Role? In that case let us know here please :-)

    This fixing of the Users' role could be something interesting to enhance a plugin or core functionality :-)

    There was an error rendering this rich post.

  • UnderDog said:

    H00j said:
    I have about 25 pages of users and several random ones have been orphaned is there away i can add them all to a group with out doing everypage manually

    I agree with what my neighbours above me said and I have something to add. Figure out why you have 25 pages of users without a Role attached. Did you delete a Role? In that case let us know here please :-)

    This fixing of the Users' role could be something interesting to enhance a plugin or core functionality :-)

    Sorry i made it unclear, i have 25pages of users, most have a role, however about 15 of the 25 do not. The delete role and migrate to another role button wouldn't work for me so i had to delete without.

  • H00jH00j
    edited April 2012

    Okay from SQL it looks like they are not orphaned they just have multiple role ids, how do i fix this so they only have one?

    --------+--------+
    | UserID | RoleID |
    +--------+--------+
    |    785 |      8 |
    |    785 |     27 |
    |    785 |     33 | 
    
  • UnderDogUnderDog MVP
    edited April 2012 Answer ✓

    I have no solution, but a couple of MySQL selects to figure out more information:
    All users which do not have a Role in the UserRole table:

    select u.UserID
    from GDN_User u
    left join GDN_UserRole ur
    on u.UserID = ur.UserID
    where ur.UserID is null;
    

    All users with multiple Roles:

    select u.UserID
    from GDN_User u
    join GDN_UserRole ur
    on u.UserID = ur.UserID
    GROUP BY ur.RoleID
    ORDER BY ur.RoleID DESC;
    

    edit
    Also figure out exactly what you want to do with which type of users.

    For example : For every user that has role 33 I want him to give only role 8
    Every user that has role 27 will only get role 33
    etcetera etcetera

    There was an error rendering this rich post.

Sign In or Register to comment.