From 3c554c0391454b8517ad4ff6193a2d157acb1054 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 14 Jun 2015 19:25:17 +0000 Subject: [PATCH] Add add_user_role and remove_user_role actions for WP_User::add_role() and remove_role(). props shooper. fixes #32060. git-svn-id: https://develop.svn.wordpress.org/trunk@32771 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/capabilities.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index d1f4419dde..6a03b8a551 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -840,6 +840,16 @@ class WP_User { update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); + + /** + * Fires immediately after the user has been given a new role. + * + * @since 4.3.0 + * + * @param int $user_id The user ID. + * @param string $role The new role. + */ + do_action( 'add_user_role', $this->ID, $role ); } /** @@ -857,6 +867,16 @@ class WP_User { update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); + + /** + * Fires immediately after a role as been removed from a user. + * + * @since 4.3.0 + * + * @param int $user_id The user ID. + * @param string $role The removed role. + */ + do_action( 'remove_user_role', $this->ID, $role ); } /**