If you want to change the abilities a hero learns dynamically (they lose learnable abilities or gain new ones), your best bet might be to screw the hero abilities all together and trigger your own hero ability learning system.
It's not as hard as it sounds--the advantage is you can swap out learnable abilities anytime anywhere, but you'll lose the traditional hero ability learning interface (the red cross with points).
Basically you make a data structure that is a wrapper around a hero unit, and has a list/array of the learnable abilities. You also keep track of how points a hero has gained in an integer, which is incremented each time a hero levels. You decrease the integer each time a player learns a new ability (costs 1 point to learn an ability) or levels one up. To make it so a hero can't learn the next level of an ability until they are lvl 3, 5, etc. there are several things you can do. You can make an array for each ability of integers where the ith member denotes the minimum hero level needed. e.g.
bash[0] = 1
bash[1] = 3
bash[2] = 5
So to learn level 3 bash, a hero needs to be at least level 5. Then they can put a skill point to learn it.
Finally, to interface with your custom/virtual ability learning menu, you can use a dialog and make each ability a button. Might sound tricky but it's quite easy if you've used dialogs before.
Now this will allow you to swap out learnable abilities or add new ones or remove them. Keep in mind you will be limited by your command card, unless you have a spell book ability to put the additional hero spells.
Here's a small sample to get you started, if this is a direction that you think makes sense
JASS:
library HeroStruct
globals
constant integer MAX_ABILITIES = 10 //arbitrary value really, can be changed
endglobals
struct Hero
//learnable ability is another struct you'll need to make
LearnableAbility array[MAX_ABILITIES]
integer points = 1 //keeps track of the total points; heroes by default start with 1 point
unit u //a handle on the hero we're managing
static method create takes unit u returns thistype
…
endmethod
…
…
endstruct
and a library for abilities
JASS:
library LearnableAbilityStruct
globals
endglobals
struct LearnableAbility
integer abilityId //the raw code of the ability in question
integer array levelRequirements
//the ith member denotes the minimum hero lvl to learn the ability
//at the ith level
static method create takes integer abilityId returns thistype
…
endmethod
…
method learn takes Hero hero returns nothing
//code here to add the ability to the hero
...
endmethod
method levelUp takes Hero hero returns nothing
//sets the ability to the next level
//you need to check outside this method if the hero is at the requisite level
…
endmethod
endstruct
endlibrary
These aren't complete by any means (don't copy and paste) but just ideas if you really want a powerful, flexible, custom hero ability learning system.