@peterupaulo Thanks for clarifying.
I don’t think I should add this as an option to the plugin for a couple of reasons:
- Of the 400+ installs, you are the first to request this configuration.
- Expired memberships can usually be renewed, so deleting a member’s WordPress user would mean rebuilding it. This doesn’t make sense to me for most cases.
What I suggest is that you look at the civi_wp_member_sync_rule_apply_roles_expired
action which allows you to know when a WordPress user has the expired
role applied to it. The parameters should give you enough context to make sure you’re dealing with the correct event to delete the user in question.
You will also have to prevent a new WordPress user from being created if you keep the CiviCRM membership record because any change to that record will cause one to be created. This can be overridden with the civi_wp_member_sync_auto_create_wp_user
filter.
Cheers, Christian