Skip to content

WordPress Automations

Add a User Role Automatically When Someone Logs In to WordPress

Want to grant a user an extra role based on their sign-in activity? Zapify automates it: when a user logs in, it adds the role you choose — keeping their existing roles by default. This guide builds the automation with the free A user logs in trigger and the free Add a role to a user action, with no code.

What is this automation?

A Zapify automation follows one rule: when this happens, do this. Here the trigger is A user logs in (WordPress) and the action is Add a role to a user (WordPress). Each time a user signs in interactively, Zapify gives them the role you selected. With Replace existing roles off, the role is simply added, so a user who already has it keeps it and nothing is lost.

Both the trigger and the action are free. The login trigger fires on an interactive sign-in, not on every authenticated page view.

How to build the role-on-login automation

Step 1: Create a new automation

  1. In your WordPress dashboard, open Zapify → Automations.
  2. Click Add New to open the Builder.
  3. Name it clearly, such as Add Member Role on Login.

Create Automation Button

Automation Name

Step 2: Add the "A user logs in" trigger

  1. In the Builder, pick the trigger and choose the WordPress integration.
  2. Select A user logs in.

This trigger fires on each successful, interactive login.

Trigger Button

Select Wordpress

A user logs in

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

  1. Below the trigger, add an action and choose the WordPress integration.
  2. Select Add a role to a user.

Action Button

Select Wordpress as Action

Select "Add a Role to User" Action

Step 4: Leave the User field empty to target the person logging in

The action's User field decides who receives the role. Its description reads "Leave empty to use the user this automation is running for." Because the A user logs in trigger starts this run, leaving User empty applies the role to the person who just signed in.

Fill in User (with an ID, an email, or a token) only when you want to act on a different user.

Select User

Step 5: Choose the role

Select the role from the Role field. It lists the roles that exist on your site, so pick, for example, Member — or any custom role you've created.

Select Role

Step 6: Decide whether to replace existing roles

The Replace existing roles checkbox controls how the role is applied:

Setting Result
Off (default) The selected role is added; the user keeps all their current roles.
On The selected role replaces every role the user currently has.

To grant an additional role on login, leave it Off. Turn it On only when you genuinely want to strip a user's other roles — otherwise you could demote an editor to a subscriber by accident.

Select "Replace Existing Role"

Step 7: Set each step Live and save

  1. Set the A user logs in trigger to Live.
  2. Set the Add a role to a user action to Live.
  3. Click Save.

Each step has its own Live / Off / Draft switch. A step on Draft is skipped, so the role is only assigned when both are Live.

"Set Live" Button to activate Automation

Step 8: Test it

Log in with a test user, then open that user's profile in Users → All Users and check the Role column. The role you chose should be listed. Open Zapify → Logs to confirm the run.

Tokens used in this automation

The core setup needs no tokens — leaving User empty targets the person logging in. The A user logs in trigger still exposes these tokens for any later action:

Token Value
User ID The user who logged in.
Username Their login name.
User email Their email address.
Display name Their display name.
User role Their current role.
Registration date When they registered.

The action outputs User ID and Role tokens for later actions in the same automation.

Refining the automation (PRO)

The steps above add the role on every login. To add it only for certain users — a specific existing role, for example — Zapify PRO adds Conditions.

PRO feature

Conditions (deciding which logins receive the role) and Delays (waiting before the role is added) are Zapify PRO features. Adding a role on login, as described above, is free.

Conclusion

With the free A user logs in trigger and Add a role to a user action, Zapify grants a role automatically whenever a user signs in — added alongside their existing roles by default. Leave User empty, pick the role, keep Replace existing roles off, set both steps Live, and save. To assign roles at sign-up instead, see Add a user role when someone registers, or update a user's details on login and email the user when their role changes.

FAQs

Will the role be added every time the user logs in?

The automation runs on each successful login, so the action fires every time. If the user already has the role, adding it again changes nothing — WordPress simply keeps the single role. So repeated logins are safe and don't stack duplicate roles.

How does Zapify know which user to give the role to?

Leave the action's User field empty. Its description says "Leave empty to use the user this automation is running for," and because the login trigger starts the run, the empty field resolves to the person who just signed in. Fill in User only to act on someone else.

Will the user's existing roles be removed?

Not while Replace existing roles is off, which is the default — the new role is simply added and every current role is kept. Turning it on replaces all of the user's roles with the selected one, so leave it off unless removing their other roles is exactly what you want.

Can I use a custom role?

Yes. The Role field lists every role that exists on your site, including any custom roles you've created, so select it just like a standard role. If a role isn't listed, create it first (with your membership plugin or a role editor) so Zapify can see it.

Does this affect users who aren't logging in?

No. The trigger is A user logs in, so the automation only runs when a user actually signs in. Users who are already authenticated by cookie, or who never log in during the period the automation is live, are not affected.

How do I confirm the role was added?

Open the user's profile in Users → All Users and check the Role column, or open Zapify → Logs to see the run. The log records the role and the user ID the action acted on, so you can verify the automation ran even if you can't inspect the profile right away.

Was this page helpful?