Cleanup When Members Change Roles
When a member’s role or BuddyPress member type changes, the plugin can automatically remove the connections it created for them. Friendships that members formed on their own are never touched.
Configure this on WB Plugins → Auto Friends → Auto-Friendship under “When a Member Changes.”

What gets removed
Section titled “What gets removed”The plugin tracks every friendship it created by storing the friend’s user ID in the _bautof_auto_created_friends user meta entry (introduced in 1.8.2). When a member loses an eligible role or member type, only those tracked friendship IDs are removed - never manual ones.
Two checkboxes
Section titled “Two checkboxes”| Checkbox | Option key | Effect |
|---|---|---|
| Unfriend when a member loses one of the eligible roles | cleanup_on_role_removal |
Removes plugin-created connections when a member loses all qualifying roles |
| Unfriend when a member loses one of the eligible member types | cleanup_on_member_type_removal |
Same behavior tied to BuddyPress member types |
Leave both unchecked if you want auto-friendships to be permanent regardless of role changes - useful for “graduate” flows where a Subscriber is promoted to a paid Member and should keep all existing connections.
Real-world examples
Section titled “Real-world examples”Downgrade flow: A monthly subscriber lapses to the Subscriber role. With role cleanup enabled, the plugin removes the auto-created friendships it made for them, giving the subscription a fresh-start feel on resubscription. Their manually-added friends stay.
Member-type rotation: A “Mentor” member type is reassigned to “Mentee” via a third-party LMS plugin. With member-type cleanup enabled, the auto-friendships the plugin created when they were a Mentor are removed cleanly.
Permanent flow: A learning platform where course completions frequently reassign roles. Leave both checkboxes off - friendships accumulate and stay even as roles cycle.
Code path
Section titled “Code path”remove_user_role → bautof_cleanup_friendships_on_role_removal()bp_remove_member_type → bautof_cleanup_friendships_on_member_type_removal()bp_set_member_type (replace) → bautof_handle_member_type_change_cleanup() → bautof_remove_auto_created_friendships()bautof_remove_auto_created_friendships() reads _bautof_auto_created_friends, calls friends_remove_friend() for each tracked ID, then removes that ID from the meta entry.
What is never touched
Section titled “What is never touched”- Friendships members accepted or sent themselves.
- Friendships created by other plugins.
- Friendships with Global Friends.

