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

A plugin without a UI would be adequate for me. What do you use to run such thing on schedule?