Remove_role not working, gives “Call to undefined method stdClass::remove_role()”
It looks like your $user variable contents are not an instance of a WP_User class. You’ve got an error of stdClass, but you need the WP_User. Check what class the $user is the instance. If you use the get_users() function, you should note one feature of this function described in the documentation: Return value is … Read more