Can I create a plugin that checks users and grant access to group based on activity?

You can do that with custom badges. The feature is now turned off by default, but if you’re self hosted you can turn it on.