Title: Programmatically Adding &amp; Disabling Users
Last modified: February 29, 2024

---

# Programmatically Adding & Disabling Users

 *  Resolved [sgordytn](https://wordpress.org/support/users/sgordytn/)
 * (@sgordytn)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-adding-disabling-users/)
 * I have a number of employees who regularly join and leave my organization, I 
   was wondering if there is some information about how to add or disable users 
   in Authorizer using a script of some sort?
 * TY in advance.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * (@figureone)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-adding-disabling-users/#post-17480079)
 * We considered adding something like this for a long time but decided it was really
   tough to scale across all authentication providers. The core issues is there’s
   no consistent way to receive a message for a “deprovisioning” event.
 * For your specific case, I’d suggest a cron job with a script that:
    - Uses WP-CLI to fetch all WordPress users [https://developer.wordpress.org/cli/commands/user/list/](https://developer.wordpress.org/cli/commands/user/list/)
    - Fetches all active users from your auth backend
    - Do an array diff to find the WordPress users not in the auth backend and use
      WP-CLI to remove their role [https://developer.wordpress.org/cli/commands/user/remove-role/](https://developer.wordpress.org/cli/commands/user/remove-role/)
      or delete them [https://developer.wordpress.org/cli/commands/user/delete/](https://developer.wordpress.org/cli/commands/user/delete/)
 * You might need to filter out some WordPress users that aren’t on the auth backend
   but shouldn’t be deleted.
 * One other option is to configure Authorizer to disable WordPress logins. This
   means folks can only log in if they have an active account on the backend. Downsides
   are you can’t log in if the auth backend goes down, and deprovisioned users who
   are still logged into WordPress will remain logged in until their WordPress login
   cookie expires.

Viewing 1 replies (of 1 total)

The topic ‘Programmatically Adding & Disabling Users’ is closed to new replies.

 * ![](https://ps.w.org/authorizer/assets/icon-256x256.jpg?rev=1967453)
 * [Authorizer](https://wordpress.org/plugins/authorizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/authorizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/authorizer/)
 * [Active Topics](https://wordpress.org/support/plugin/authorizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/authorizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/authorizer/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-adding-disabling-users/#post-17480079)
 * Status: resolved