remove_user_role

remove_user_role

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wordpress-6.7.2

do_action('remove_user_role') is found 2 times:

  • /wp-includes/class-wp-user.php line 595
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
         *
         * @param int    $user_id The user ID.
         * @param string $role    The removed role.
         */
        do_action( 'remove_user_role', $this->ID, $role );
    }
     
    /**
     * Sets the role of the user.
     *
     * This will remove the previous roles of the user and assign the user the
  • /wp-includes/class-wp-user.php line 637
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
            continue;
        }
     
        /** This action is documented in wp-includes/class-wp-user.php */
        do_action( 'remove_user_role', $this->ID, $old_role );
    }
     
    if ( $role && ! in_array( $role, $old_roles, true ) ) {
        /** This action is documented in wp-includes/class-wp-user.php */
        do_action( 'add_user_role', $this->ID, $role );
    }

See this hook used in plugins: