Skip to content

BuddyPress Automations

Add a Role to Both Members When a BuddyPress Friendship Is Accepted

Members who connect with each other are the members who stay. A simple way to recognise that is to give people who have made a connection a role of their own — "Connected Member", say — that unlocks a members-only area, a badge on your site, or a discount. Zapify does this with the A user accepts a friendship request trigger and two Add a role to a user actions, one for each person in the friendship.

What this automation does

The automation is one trigger plus two actions:

  • Trigger: A user accepts a friendship request (BP_FRIENDSHIP_ACCEPTED, BuddyPress)
  • Action 1: Add a role to a user (WP_ADD_USER_ROLE, WordPress), for the member who accepted
  • Action 2: Add a role to a user (WP_ADD_USER_ROLE, WordPress), for the member who sent the request

When a friendship request is accepted, both members end up with the role you choose.

Two people are involved, so it helps to know who is who. The automation runs for the member who accepted the request, so an action with its User field empty acts on them. The member who originally sent the request is described by the Friend tokens, and that is how the second action reaches them.

Before you start

  • BuddyPress must be installed and active, with the Friend Connections component switched on in your BuddyPress settings. Zapify's BuddyPress integration is not available on sites running BuddyBoss Platform.
  • The role must already exist.

How to build the automation

Step 1: Create a new automation

  1. In the WordPress admin, go to Zapify → Automations.
  2. Click Add New to open the builder.
  3. Name it clearly, such as Give Connected Member role to both friends.

Create a new automation

Step 2: Add the "A user accepts a friendship request" trigger

  1. Click Add Trigger.
  2. Choose BuddyPress as the app.
  3. Select the trigger A user accepts a friendship request.

This trigger has no settings to fill in.

Add a trigger

Select BuddyPress as the trigger

Select A user accepts a friendship request

Step 3: Add the first "Add a role to a user" action

This one is for the member who accepted the request.

  1. Click Add Action.
  2. Choose WordPress as the app.
  3. Select Add a role to a user.
  4. Choose the Role to grant, such as Connected Member.
  5. Leave User empty. Zapify uses the member who accepted.

Add an action

Select WordPress as the action

Select Add a role to a user

Choose the role to add

Step 4: Add the second "Add a role to a user" action

This one is for the member who sent the request.

  1. Click Add Action again and choose WordPress → Add a role to a user.
  2. Choose the same Role.
  3. In the User field, click the {} token button and insert the Friend ID token. That is the member who sent the request.

Insert the Friend ID token in the User field

Field Required What it does
Role Yes The role to grant — pick from your site's registered roles.
Replace existing roles No Off (default) keeps the roles the member already has. On replaces them with just this one.
User No Empty means the member who accepted. Insert Friend ID to act on the member who sent the request instead.

Be careful with Replace existing roles

Leave Replace existing roles switched off unless you are sure. When it is on, the member keeps only the new role, so an administrator or editor who accepts a request could lose their existing access.

Step 5: Set the steps Live and save

  1. Set the trigger and both actions to Live.
  2. Click Save.

Set the automation live

Tokens you can use

The Friend tokens describe the member who sent the request.

Token What it holds
Friendship ID The numeric ID of the friendship record.
Friend ID The member's numeric ID.
Friend name The member's display name.
Friend email The member's email address.
Friend first name / Friend last name The member's name fields.
Friend profile URL The link to the member's profile.

The member who accepted is available as the usual user tokens, such as User email and Display name.

How to test it

  1. Log in as one test member and send a friendship request to a second test member.
  2. Log in as the second member and accept the request.
  3. Open Users in the WordPress admin and confirm both test members now have the role.
  4. If one is missing the role, open Zapify → Logs to see which step ran and what it reported.

Conclusion

With the A user accepts a friendship request trigger and two Add a role to a user actions, Zapify rewards both sides of every new connection on the free plan. Next, let members know when someone wants to connect with send an email when a friendship request is sent.

FAQs

Why two actions instead of one?

Each Add a role to a user action acts on one person. The first uses the member who accepted, by default. The second points its User field at the Friend ID token so it reaches the member who sent the request.

Can I give the roles only on a member's first friendship?

Not on the free plan. The automation runs for every accepted request. Adding a role a member already has changes nothing, so repeat runs are harmless, but you cannot make it run for a first friendship only.

Does the role get removed if the friendship ends?

No. This automation only adds roles. It does not watch for friendships being removed.

Is this feature free?

Yes. BuddyPress is a free Zapify integration, and both the A user accepts a friendship request trigger and the Add a role to a user action are included in the free plan.

Do I need to write any code?

No. Everything is configured in the Zapify visual builder.

Was this page helpful?