To determine whether to use whoever or whomever, the he/him rule in the Who/Whom section applies:
he = whoever
him = whomever
Rule 1. The presence of whoever or whomever indicates a dependent clause. Use whoever or whomever to agree with the verb in that dependent clause, regardless of the rest of the sentence.
Give it to whoever/whomever asks for it first.
He asks for it first. Therefore, whoever is correct.
We will hire whoever/whomever you recommend.
You recommend him. Therefore, whomever is correct.
We will hire whoever/whomever is most qualified.
He is most qualified. Therefore, whoever is correct.
Rule 2. When the entire whoever/whomever clause is the subject of the verb that follows the clause, look inside the clause to determine whether to use whoever or whomever.
Whoever is elected will serve a four-year term.
Whoever is the subject of is elected. The clause whoever is elected is the subject of will serve.
Whomever you elect will serve a four-year term.
Whomever is the object of elect. Whomever you elect is the subject of will serve.
A word to the wise: Whomever is even more of a vogue word than whom. Many use it indiscriminately to sound cultured, figuring that no one will know any better.