add_user_role

add_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('add_user_role') is found 2 times:

  • /wp-includes/class-wp-user.php line 567
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
         *
         * @param int    $user_id The user ID.
         * @param string $role    The new role.
         */
        do_action( 'add_user_role', $this->ID, $role );
    }
     
    /**
     * Removes role from user.
     *
     * @since 2.0.0
  • /wp-includes/class-wp-user.php line 642
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    }
     
    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 );
    }
     
    /**
     * Fires after the user's role has changed.
     *
     * @since 2.9.0

See this hook used in plugins: