Skip to content

Dynamic Processing - Auto-Update Friendships on Role or Type Changes

Dynamic processing extends auto-friendship creation beyond new user registrations. When enabled, the plugin automatically creates or removes friendships whenever an existing user’s WordPress role or BuddyPress member type changes.

When an admin assigns a user to a role or member type that qualifies under the current welcome-group rules, the plugin schedules a friendship creation job for that user. The job runs in the background via WordPress cron and runs the same welcome-group logic used at registration: the user is friended with every existing member who holds any of the configured welcome-group roles or member types, plus all Global Friends.

Dynamic processing also supports cleanup: when a user loses a role or member type they previously held, the plugin can optionally remove the auto-created friendships that were originally produced for that user.

Dynamic processing is always active - the plugin listens to role and member-type change events at all times. There is no on/off toggle for this behavior.

The plugin hooks into:

  • set_user_role - role completely replaced
  • add_user_role - a role is added to a user’s existing roles
  • remove_user_role - a role is removed
  • bp_set_member_type - member type set (or replaced)
  • bp_remove_member_type - member type removed

When any of these events fires for a user who now qualifies (or previously qualified) under the welcome-group rules, the plugin schedules bautof_create_friendships_event for that user. If an event for that user is already queued, no duplicate is scheduled.

Configure this on the Auto-Friendship tab under “When a Member Changes.”

When a user is removed from a qualifying role and no longer has any other qualifying role, the plugin can remove the friendships it auto-created for that user.

To enable: check Unfriend when a member loses one of the eligible roles on the Auto-Friendship tab and save.

Cleanup only touches friendships tracked in _bautof_auto_created_friends user meta. Friendships your members built manually, and friendships with Global Friends, are always preserved.

Same logic as role removal, but triggered by BuddyPress member type changes.

To enable: check Unfriend when a member loses one of the eligible member types on the Auto-Friendship tab and save.

When bp_set_member_type() is called with a replacement (non-append) operation, the plugin checks whether the user lost all qualifying member types and removes affected auto-friendships if so.

Dynamic processing never blocks the current admin request. The plugin schedules a single cron event per user change:

bautof_create_friendships_event

If a cron event for that user is already queued, no duplicate is scheduled.

Site type Cleanup setting
Open community (roles rarely change) Off - friendships accumulate naturally
Structured community (roles define access tiers) On - friendships reflect current access level
Large site (10,000+ users) Review impact before enabling; test on staging first

On large sites, enabling cleanup can trigger many friendship deletions when roles are bulk-changed.