Requesting help demoting users with invalid email addresses

Could you use the bulk admin task in this case?


Though I’ve just tested your second code out and it worked for me on my test user (email: test_thirteen@here.invalid, was TL1 and is now TL0).

User.where(trust_level: 1).each do |u|
   if u.primary_email&.email.end_with?(".invalid")  
     u.change_trust_level!(TrustLevel[0])    
   end  
end
3 Likes