WP_Roles::remove_role()publicWP 2.0.0

Removes a role by name.

Метод класса: WP_Roles{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

global $wp_roles;
$wp_roles->remove_role( $role );
$role(строка) (обязательный)
Role name.

Список изменений

С версии 2.0.0 Введена.

Код WP_Roles::remove_role() WP 6.5.2

public function remove_role( $role ) {
	if ( ! isset( $this->role_objects[ $role ] ) ) {
		return;
	}

	unset( $this->role_objects[ $role ] );
	unset( $this->role_names[ $role ] );
	unset( $this->roles[ $role ] );

	if ( $this->use_db ) {
		update_option( $this->role_key, $this->roles );
	}

	if ( get_option( 'default_role' ) === $role ) {
		update_option( 'default_role', 'subscriber' );
	}
}