Skip to content

WordPress Automations

Add a Role to a User When They Click a Button

Sometimes access should be a one-click choice: "Join the beta", "Become a subscriber", "Unlock the member area". Zapify handles that with the A user clicks a button trigger and the Add a role to a user action. Both are free.

For how buttons and keys work in detail, see Buttons.

What this automation does

The automation is one trigger plus one action:

  • Trigger: A user clicks a button (BUTTON_CLICKED, Buttons)
  • Action: Add a role to a user (WP_ADD_USER_ROLE, WordPress)

When a logged-in visitor clicks the button that matches the trigger's key, Zapify grants them the role you choose.

Before you start

  • The role you want to grant must already exist.
  • Only logged-in visitors can click a button; logged-out visitors see Log in to do this.
  • Both the trigger and the action are free.

Choose the role carefully

Anyone who can see the button can grant themselves this role. Use it for low-privilege roles like a "beta tester" or "member" role — never for anything with administrative rights.

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 Join the beta.

Create a new automation

Step 2: Add the "A user clicks a button" trigger

  1. Click Add Trigger.

Add a trigger

  1. Choose Buttons as the app.

Select Buttons as the trigger

  1. Select A user clicks a button.
  2. In Button key, type a name of your choice, for example join-beta.

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

  1. Click Add Action.

Add an action

  1. Choose WordPress as the app.

Select WordPress as the action

  1. Select Add a role to a user.

Select Add a role to a user

  1. Pick the Role, and leave User empty so it applies to whoever clicked.

Choose the role to add

Step 4: Set the steps Live and save

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

Set the automation live

Step 5: Place the button on a page

Add this shortcode to any page, post or widget, using the same key:

[zapify_button key="join-beta" label="Join the beta"]

Tokens you can use

Token What it holds
Who clicked The user's ID.
Their email address The clicker's email.
Their username The clicker's username.
Their display name The clicker's display name.
Page it was clicked from The URL of the page holding the button.

How to test it

  1. Log in as a test user and open the page with the button.
  2. Click it and check the user's roles in Users.
  3. If nothing changes, open Zapify → Logs, and confirm the shortcode's key matches the trigger's key exactly.

Conclusion

With the A user clicks a button trigger and the Add a role to a user action, Zapify turns a single click into access. Next, read the full guide to Buttons, or add a confirmation with send a welcome email.

FAQs

Can someone click the button twice?

The automation runs once per user by default, so repeat clicks don't repeat the action.

Is this feature free?

Yes. Both the trigger and the action are free.

Do I need to write any code?

No — you only paste a shortcode onto the page.

Was this page helpful?