WP query is calling get_userdata and throws error [closed]

You need to call that code from within a hook. Calling it directly inside your plugin is way too soon – get_userdata is a pluggable function and will not yet be loaded.